Free, open-source AI video generator for Mac. Run LTX-2.5 and MiniMax H3 (Hailuo) locally on Apple Silicon: text-to-video and image-to-video with sound, lip-sync, character LoRA training, songs from lyrics (YuE2) and image editing (Qwen-Image-Edit). One-click install via Pinokio. Offline: no cloud, no API key, no NVIDIA GPU.
Python ai-filmmakingai-videoai-video-generatorapple-siliconhailuoimage-to-videolip-synclocal-ailora-trainingltx-2ltx-2-5ltx-videomacosminimax-h3mlxmusic-generationoffline-aipinokiotext-to-videovideo-generation
fix(image/infra): HiDream deadline, Qwen LoRA guard, atomic stats, scenema bind, stats gitignore
mrbizarro27604dea82f8
diff --git a/.gitignore b/.gitignoreindex b919450..21a844a 100644--- a/.gitignore+++ b/.gitignore@@ -11,6 +11,15 @@ state/panel_queue.jsonpanel_hidden.jsonpanel_settings.json+# 2026-05-31 review: defense-in-depth for the private GitHub-stats data.+# `state/` is an fs.link symlink off-repo, so `git check-ignore+# state/stats-data.jsonl` reports "beyond a symbolic link" — i.e. the only+# thing protecting it today is that it lives outside the repo. A basename+# rule covers it even if PHOSPHENE_STATS_OUT is pointed somewhere tracked,+# or the symlink is ever replaced with a real dir. (A snapshot leaked once+# to docs/stats-data.jsonl — rolled back in 70b4489. Never again.)+**/stats-data.jsonl+stats-data.jsonl*.log*.tmpdiff --git a/image_engine.py b/image_engine.pyindex 7cfb102..527775a 100644--- a/image_engine.py+++ b/image_engine.py@@ -744,9 +744,32 @@ def _generate_mflux(prompt: str, n: int, width: int, height: int,# with "Could not find LoRA file ... in downloaded files". Paths that# look like real files or that don't contain a colon are passed# through untouched.- if config.mflux_lora_paths:+ # 2026-05-31 review fix (C2): the default config ships the Qwen-Edit+ # Lightning LoRA (qwen_edit is the UI default). If the engine is switched+ # to a FLUX family (e.g. via engine_override="auto") while that LoRA is+ # still in the config, mflux would load a Qwen-architecture LoRA onto a+ # FLUX transformer — a ~50s model load followed by a no-op or crash. A+ # Qwen LoRA cannot apply to a non-Qwen model, so drop cross-family LoRAs+ # (and their paired scales, kept index-aligned) up front and log it.+ _lora_paths_in = list(config.mflux_lora_paths or [])+ _lora_scales_in = list(config.mflux_lora_scales or [])+ if fam != "qwen_edit" and _lora_paths_in:+ _kept_p: list = []+ _kept_s: list = []+ for _i, _lp in enumerate(_lora_paths_in):+ if "qwen" in str(_lp).lower():+ if on_log is not None:+ try: on_log(f"[lora] skipping Qwen LoRA on {fam} family (incompatible): {_lp}")+ except Exception: # noqa: BLE001+ pass+ continue+ _kept_p.append(_lp)+ if _i < len(_lora_scales_in):+ _kept_s.append(_lora_scales_in[_i])+ _lora_paths_in, _lora_scales_in = _kept_p, _kept_s+ if _lora_paths_in:resolved_paths: list[str] = []- for lp in config.mflux_lora_paths:+ for lp in _lora_paths_in:lp_str = str(lp)# Path with a colon → repo:filename collection syntax. Skip# if the file already exists locally (e.g. a Civitai LoRA@@ -775,9 +798,17 @@ def _generate_mflux(prompt: str, n: int, width: int, height: int,resolved_paths.append(lp_str)cmd.append("--lora-paths")cmd.extend(resolved_paths)- if config.mflux_lora_scales:+ if _lora_scales_in:+ # 2026-05-31 review fix (C3): catch a scales/paths length mismatch+ # HERE rather than letting mflux discover it after a ~50s model+ # load and crash with an opaque error.+ if len(_lora_scales_in) != len(resolved_paths):+ raise ValueError(+ f"LoRA scales/paths length mismatch: {len(_lora_scales_in)} "+ f"scale(s) vs {len(resolved_paths)} path(s) — check "+ f"mflux_lora_scales / mflux_lora_paths in the engine config")cmd.append("--lora-scales")- cmd.extend(str(s) for s in config.mflux_lora_scales)+ cmd.extend(str(s) for s in _lora_scales_in)# When `--model` is a HuggingFace id or local path (contains a# slash or starts with `~`), mflux needs `--base-model` to know# which architecture to instantiate. Fall through to the per-family@@ -1425,6 +1456,29 @@ def _generate_hidream(prompt: str, n: int, width: int, height: int,start_new_session=True,)_register_active_proc(proc)+ # 2026-05-31 review fix (C1): the read loop below blocks on proc.stdout+ # with no deadline. A hung HiDream render (stalled MLX/Metal, no output,+ # never exits) would pin the queue worker forever — only a manual /stop+ # recovered. A watchdog timer SIGKILLs the process group after a generous+ # deadline so a hang self-heals. mflux already has a select()-based+ # deadline (≈:866); HiDream is dropdown-hidden (#15) so this lighter+ # watchdog is sufficient until the two streamers are unified.+ _hd_timed_out = {"v": False}+ _hd_deadline = float(os.environ.get("PHOSPHENE_HIDREAM_TIMEOUT_S", "1500"))++ def _hd_kill_on_timeout():+ _hd_timed_out["v"] = True+ try:+ os.killpg(os.getpgid(proc.pid), 9) # SIGKILL the whole group+ except Exception:+ try:+ proc.kill()+ except Exception:+ pass++ _hd_wd = threading.Timer(_hd_deadline, _hd_kill_on_timeout)+ _hd_wd.daemon = True+ _hd_wd.start()try:if proc.stdout is not None:for line in proc.stdout:@@ -1435,7 +1489,13 @@ def _generate_hidream(prompt: str, n: int, width: int, height: int,on_log(f"[hidream] {line}")rc = proc.wait()finally:+ _hd_wd.cancel()_unregister_active_proc(proc)+ if _hd_timed_out["v"]:+ raise RuntimeError(+ f"HiDream gen exceeded its {_hd_deadline:.0f}s deadline and was "+ f"killed (likely a hung render). Raise PHOSPHENE_HIDREAM_TIMEOUT_S "+ f"if your machine legitimately needs longer.")if rc != 0:# SIGTERM → rc = -15 on POSIX (or 143 if the shell wrapped it).# Treat that as cancellation, not failure, so the worker can markdiff --git a/scenema_client.py b/scenema_client.pyindex 89f40f5..2b2b987 100644--- a/scenema_client.py+++ b/scenema_client.py@@ -114,6 +114,8 @@ def serve_reference(local_path: str):parent = str(p.parent)+ target_name = p.name+class _Handler(http.server.SimpleHTTPRequestHandler):def __init__(self, *a, **k):super().__init__(*a, directory=parent, **k)@@ -121,9 +123,27 @@ def serve_reference(local_path: str):def log_message(self, fmt, *args): # silence default access logreturn- # Bind on 0.0.0.0 so a remote Scenema pod can reach us if the user has- # tunnelled. For 127.0.0.1-only deployments it works the same way.- srv = socketserver.TCPServer(("0.0.0.0", 0), _Handler)+ def list_directory(self, path):+ # 2026-05-31 review fix (D3): never expose a directory listing.+ self.send_error(403, "directory listing forbidden")+ return None++ def do_GET(self):+ # Only the exact reference file is served — everything else 404s,+ # so the parent dir can't be walked even if a crafted path slips+ # past SimpleHTTPRequestHandler's traversal guard.+ req = self.path.split("?", 1)[0].split("#", 1)[0].lstrip("/")+ if req != target_name:+ self.send_error(404, "not found")+ return+ return super().do_GET()++ # 2026-05-31 review fix (D3): bind loopback by default. The old hard+ # 0.0.0.0 bind exposed the whole parent directory to the LAN with no+ # auth. A remote Scenema pod only needs 0.0.0.0 when the user has+ # explicitly tunnelled — gate that behind SCENEMA_BIND_ALL=1.+ _bind_host = "0.0.0.0" if os.environ.get("SCENEMA_BIND_ALL") == "1" else "127.0.0.1"+ srv = socketserver.TCPServer((_bind_host, 0), _Handler)srv.allow_reuse_address = Truet = threading.Thread(target=srv.serve_forever, daemon=True)t.start()diff --git a/scripts/fetch_repo_stats.py b/scripts/fetch_repo_stats.pyindex f003838..8f7ce3a 100644--- a/scripts/fetch_repo_stats.py+++ b/scripts/fetch_repo_stats.py@@ -747,12 +747,29 @@ def main(argv: list[str] | None = None) -> int:except json.JSONDecodeError:continueexisting.append(row)- OUTPUT.write_text(- "\n".join(json.dumps(r, ensure_ascii=False) for r in existing) + "\n",- encoding="utf-8",- )- print(f" wrote {len(existing)} rows -> "- f"{OUTPUT.relative_to(OUTPUT.parent.parent)}", flush=True)+ # 2026-05-31 review fix (D1): write atomically. The old direct+ # write_text() truncated the file before writing — a crash/kill+ # mid-write (or disk-full) destroyed ALL accumulated history, and+ # clones/views older than GitHub's 14-day window are unrecoverable.+ # Temp file + fsync + os.replace: the real file is always either the+ # complete old version or the complete new version, never torn. Guard+ # against writing an empty payload over good data.+ payload = "\n".join(json.dumps(r, ensure_ascii=False) for r in existing) + "\n"+ if not existing or not payload.strip():+ print(" WARN: refusing to overwrite stats with an empty payload", flush=True)+ else:+ import os as _os+ _tmp = OUTPUT.with_name(f".{OUTPUT.name}.{_os.getpid()}.tmp")+ with open(_tmp, "w", encoding="utf-8") as _fh:+ _fh.write(payload)+ _fh.flush()+ try:+ _os.fsync(_fh.fileno())+ except OSError:+ pass+ _os.replace(_tmp, OUTPUT)+ print(f" wrote {len(existing)} rows -> "+ f"{OUTPUT.relative_to(OUTPUT.parent.parent)}", flush=True)# Summary line for GitHub Actions step output.clones_wow = _wow_delta(clones_window)