"""Minimal end-to-end vertical slice smoke test. Uses the already-running gemma-4-12b on klaus-3 as the sole surrogate (the fast 4B models are not hosted yet), a tiny search space, and one real OpenRouter target validation. Proves the whole loop: decoy -> Tier A -> gate -> Tier B. """ from __future__ import annotations import veil_pgd.optimizer.search_space as ss from veil_pgd.config import get_settings # --- shrink everything for a fast smoke test --- s = get_settings() s.surrogate_models = ("gemma-4-12b",) s.blackbox_target_models = ("google/gemini-3.5-flash",) # cheapest strong vision target s.optimizer.decoy_shortlist_size = 2 s.optimizer.grid_font_px = (16,) s.optimizer.evo_population = 3 s.optimizer.evo_generations = 1 s.budget.top_k_to_validate = 2 s.budget.max_blackbox_queries_per_image = 4 # only two placements to keep surrogate calls small ss.default_positions = lambda: ["bottom_middle", "top_right"] # type: ignore from veil_pgd.pipeline import protect_image # noqa: E402 res = protect_image("examples/sun.png", truth="sun", settings=s) m = res.manifest print("=== SLICE RESULT ===") print("truth:", m["truth"]) print("chosen text:", m["spec"]["text"]) print("spec:", {k: m["spec"][k] for k in ("font_px", "alpha", "color_strategy", "position")}) print("per_model_distance:", m["per_model_distance"]) print("stealth passed:", m["stealth"]["passed"] if m["stealth"] else None, "psnr=%.1f ssim=%.3f" % (m["stealth"]["psnr"], m["stealth"]["ssim"]) if m["stealth"] else "") print("surrogate_fitness=%.3f blackbox_fitness=%.3f" % (m["surrogate_fitness"], m["blackbox_fitness"])) print("notes.blackbox_preds:", m["notes"].get("blackbox_preds")) print("protected image:", m["protected_image"])