* refactor(launchpad): quieter, borderless design refresh The launchpad carried decoration from an earlier direction: icon chips, corner-hung count badges, a permanently visible filled arrow, uppercase mono card titles, and a dotted stipple divider — plus a frame that had been invisible since the app-wide border tokens were zeroed. Rework it around what the borderless direction actually implies: - Feature tiles get a whisper-faint surface instead of a dead frame, and read as three bands (bare glyph + count / title + arrow / description). `--card-hue` is spent sparingly — the glyph at rest, the surface, count and arrow only once raised. Titles move to sans sentence case; counts are plain tabular numerals. Lift softened 4px -> 2px, coloured glow -> neutral shadow, plus an explicit focus ring and a staggered entrance. - Hero drops the boxed "646" pill and the filled A/B-Compare button for quiet type, with a hairline standing in for the separation. - Section labels trade the dotted stipple for a single fading hairline; rows are transparent until hover and reveal "Open" on hover/focus (it stays in the DOM, so AT and keyboard always reach it). - Hero, tiles, recent files, callout and project lists now share one 1180px column — previously only the top half was capped, so lists ran edge-to-edge on a wide display while the deck stayed centred. Two bugs found and fixed while doing it: - Buttons that had `border border-solid border-transparent` removed fell back to the UA default border and rendered a visible 1px outline. They now carry `border-0` explicitly. - `.lp-animate` used `animation-fill-mode: both`, so after the entrance it kept owning `transform` — and animation-origin declarations outrank normal ones, which silently killed the card hover lift. Now `backwards`, which still holds the from-state through the stagger delay. Also drops CSS the page has not rendered since #904: the cursor-spotlight layer, the breath ring, and the per-card waveform strip. Verified with headless renders at 1600/1280/940 and the empty state. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(dictation): decode Wayland portal signals and show the capture pill The GlobalShortcuts portal declares Activated/Deactivated as (o session, s shortcut_id, t timestamp, a{sv} options). We decoded the timestamp as u32, so zbus rejected every signal with Signature mismatch: got `(osta{sv})`, expected `(osua{sv})` and the press was dropped as an invalid signal. Registration succeeded and the desktop even reported the bound chord back, so the hotkey looked wired up while doing nothing at all — on every Wayland compositor, for the whole life of the feature (#1490). Decode the 64-bit timestamp, and keep the 32-bit spelling as a fallback so a non-conforming portal degrades to working rather than to silence. With presses arriving, the second half of the failure showed: nothing had shown the widget window since it became a hidden recorder host, so a capture ran with no pill on screen — and a mic or Accessibility failure rendered into a window nobody could see. Add show_dictation_pill, which bottom-centres the capsule on the monitor under the pointer and shows it without taking focus (Windows keeps SW_SHOWNOACTIVATE so paste still lands in the user's document), and call it from the widget for every state but idle. Wayland denies clients their own placement, so the compositor picks the spot there; the pill still appears. dispatch_dictation_capture now logs whether a press was emitted or queued — a press that reaches Rust and produces nothing was otherwise indistinguishable from one the compositor never delivered. Tests: portal signals decode at both timestamp widths (the 64-bit case fails before this change with the exact production error); pill placement centres, respects a second monitor's origin, and clamps rather than going off-screen; the widget shows for a state needing the user, stays hidden while idle, and never shows for a press that arrives while dictation is disabled. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * chore: sync in-progress workspace changes Uncommitted work already in the tree, checkpointed so the branch matches the local machine: - Remote GPU workers: join-from-the-app flow, one-time secrets, QR join codes, a Compute control in the status bar, and the device-list Workers panel (#1516) - Model Catalogue workspace, with Settings pointing at it - Settings sidebar search and keyboard navigation - Demo assets for dubbing, dictation and voice design, plus the scripts that render them - Backend: validation-error handling, ASR request-path degradation, and the accompanying tests - CHANGELOG entries for the above and for the Wayland dictation fix Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(tests): follow Engines to the Model Catalogue, and green the sweep - test_supertonic3 asserted the license gate points at "Settings" while the engine now names Model Catalogue → Engines, which is where the accept button actually lives. The assertion follows the move; what it pins is unchanged — the hint must name a place the user can reach it. - Carries the CJK allowlist entries for the rendered dub bundle (#1517) and the regenerated route snapshot for /workers/agent (#1516), both of which this branch inherits from the workspace sync. - docs/install/linux.md: the dictation capsule is bottom-anchored everywhere except Wayland, where the protocol gives applications no say in their placement. Documented rather than left as a surprise (CodeRabbit). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * ci: stop a flaky dependency fetch from failing green runs en-core-web-sm resolves to a direct GitHub release URL, and github.com intermittently answers `http2 error: refused stream before processing any application logic`. uv's own three retries all land within the same few seconds and fail together, so the whole job dies on a dependency that has nothing to do with the change under test — it cost #1518 and #1517 an otherwise-green run tonight. Two changes: back off between whole `uv sync` attempts, which is what actually clears it, and pass --no-sync to the pytest steps. `uv run` re-resolves the environment before running, so every test step was a fresh chance to hit the same fetch even though the install step had already synced — that is exactly how #1518 failed, in the isolated backend/tests step, with all 5467 tests already passed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * ci: one retry seam for every uv sync, not just the job that failed last en-core-web-sm resolves to a direct GitHub *release* URL rather than a package index, and github.com intermittently answers `http2 error: refused stream before processing any application logic`. uv's own retries all land inside the same ~10 seconds and fail together, so a job dies on a dependency unrelated to the change under test. Tonight that cost four otherwise-green runs across #1515, #1517 and #1518 — and the first fix only covered the Tests job, so the next failure simply moved to Smoke (Linux), which syncs separately. The fetch is per-job, so the fix has to be per-job: scripts/uv-sync-retry.sh backs off between whole attempts (15s, 45s, 90s) and every workflow that syncs now goes through it — ci.yml (tests + the platform matrix), release.yml, security.yml, evals.yml. It still fails loudly after four attempts, so a genuinely broken lockfile is not disguised as a flake. The Tests job also lacked the UV_HTTP_TIMEOUT / UV_HTTP_RETRIES the smoke matrix has always set, which is part of why it was the one that kept dying; it has them now. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * test(ci): pin the Intel-Mac contract by intent, not by command spelling test_ci_verifies_intel_mac_as_the_documented_remote_only_host asserted the literal line `run: uv sync --extra pockettts`, so routing every sync through scripts/uv-sync-retry.sh read as a broken Intel-Mac contract. The contract it exists to protect is that the pockettts extra installs ONLY on backend_supported legs — which the regex now pins, while leaving how the sync is invoked free to change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * ci: keep every uv run out of the resolver, and bound the retry budget CodeRabbit, #1517: - `uv run` re-resolves before running, so the smoke suite, the worker-artifact tests, the release test run and the eval run were each a fresh chance to hit the flaky direct-URL fetch outside the retry loop. All of them pass --no-sync now; the environment is already synced by the step that owns the retries. security.yml's `uv run --with pip-audit` is deliberately left alone — it layers an ephemeral package rather than running the project's own tests. - The retry count multiplied uv's own budget (UV_HTTP_RETRIES=5 with a 120 s timeout on the smoke matrix). Three attempts and 60 s of total backoff outlast the refusals actually observed while staying well inside the jobs' timeout-minutes. - The Intel-Mac contract test pinned the smoke command literally too, so --no-sync tripped it exactly like the sync line did. Same fix: assert the contract (smoke runs only on backend_supported legs), not its spelling. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
384 lines
16 KiB
Python
384 lines
16 KiB
Python
"""Tests for Supertonic-3 engine (Phase 3 Plan 03-01).
|
||
|
||
Covers TTS-01..06 from REQUIREMENTS.md. The 3-language smoke test
|
||
(TTS-06) is gated on ``OMNIVOICE_SMOKE=1`` because it downloads ~400 MB
|
||
of model weights from HuggingFace. All other tests run on every CI
|
||
invocation and never touch the network.
|
||
"""
|
||
from __future__ import annotations
|
||
|
||
import builtins
|
||
import importlib
|
||
import importlib.util
|
||
import os
|
||
import re
|
||
import subprocess
|
||
import sys
|
||
import tomllib
|
||
from pathlib import Path
|
||
|
||
import pytest
|
||
|
||
|
||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||
SUPERTONIC_SMOKE = os.environ.get("OMNIVOICE_SMOKE") == "1"
|
||
|
||
# The license-gate / CPU-honesty tests exercise logic that only runs once the
|
||
# optional `supertonic` package is importable (is_available() short-circuits
|
||
# with a "not installed" reason otherwise). ci.yml runs `uv sync --all-extras`
|
||
# and exercises them; release.yml + a plain local `uv sync` don't install
|
||
# optional engines, so skip there rather than fail. The absent-package path is
|
||
# covered independently by test_optional_dep_missing.
|
||
_SUPERTONIC_INSTALLED = importlib.util.find_spec("supertonic") is not None
|
||
|
||
|
||
# ── TTS-02: optional-dep pin ──────────────────────────────────────────────
|
||
|
||
|
||
def test_optional_dep_pin():
|
||
"""``pyproject.toml`` exposes a ``supertonic`` optional-dependency
|
||
entry with the version approved by Task 1 (1.3.1 default)."""
|
||
pyproject = REPO_ROOT / "pyproject.toml"
|
||
with pyproject.open("rb") as f:
|
||
data = tomllib.load(f)
|
||
opt = data["project"].get("optional-dependencies", {})
|
||
assert "supertonic" in opt, (
|
||
"pyproject.toml is missing the [project.optional-dependencies] "
|
||
"supertonic = [...] entry"
|
||
)
|
||
pins = opt["supertonic"]
|
||
assert isinstance(pins, list) and pins, "supertonic extra must list >=1 pin"
|
||
# Approved version from Plan 03-01 Task 1 checkpoint = 1.3.1.
|
||
assert any("supertonic==1.3.1" in p or "supertonic==1.2.3" in p for p in pins), (
|
||
f"supertonic optional-dep pin must be ==1.3.1 (Task 1 approved) "
|
||
f"or ==1.2.3 (fallback); got {pins!r}"
|
||
)
|
||
|
||
|
||
# ── TTS-02: single onnxruntime row in lockfile ────────────────────────────
|
||
|
||
|
||
def test_lockfile_no_onnxruntime_double_install():
|
||
"""``uv.lock`` declares exactly one ``onnxruntime`` distribution.
|
||
|
||
Pitfall 1 / T-03-05: if a future engine bumps in ``onnxruntime-gpu``,
|
||
the CPU and GPU builds will both ship and one will issue a warning
|
||
at import time. The plan-time smoke must catch that before it lands.
|
||
"""
|
||
lockfile = REPO_ROOT / "uv.lock"
|
||
text = lockfile.read_text(encoding="utf-8")
|
||
# Distribution names appear as ``name = "<pkg>"`` lines in uv.lock.
|
||
cpu_rows = re.findall(r'^name = "onnxruntime"\s*$', text, re.MULTILINE)
|
||
gpu_rows = re.findall(r'^name = "onnxruntime-gpu"\s*$', text, re.MULTILINE)
|
||
assert len(cpu_rows) == 1, (
|
||
f"expected exactly 1 'onnxruntime' row in uv.lock, found {len(cpu_rows)}"
|
||
)
|
||
assert len(gpu_rows) == 0, (
|
||
f"uv.lock contains an onnxruntime-gpu row "
|
||
f"(double-install risk per Pitfall 1)"
|
||
)
|
||
|
||
|
||
# ── TTS-03: SHA pin format ────────────────────────────────────────────────
|
||
|
||
|
||
def test_pinned_sha_format():
|
||
"""``PINNED_REVISION_SHA`` is exactly 40 lowercase hex chars."""
|
||
from engines.supertonic3 import constants
|
||
|
||
sha = constants.PINNED_REVISION_SHA
|
||
assert isinstance(sha, str), "PINNED_REVISION_SHA must be a str"
|
||
assert len(sha) == 40, f"expected 40-char SHA, got {len(sha)}: {sha!r}"
|
||
assert all(c in "0123456789abcdef" for c in sha), (
|
||
f"PINNED_REVISION_SHA must be lowercase hex, got {sha!r}"
|
||
)
|
||
|
||
|
||
@pytest.mark.skipif(
|
||
not SUPERTONIC_SMOKE,
|
||
reason="network test; set OMNIVOICE_SMOKE=1 to run",
|
||
)
|
||
def test_sha_resolves():
|
||
"""``PINNED_REVISION_SHA`` exists on the actual HuggingFace commit log.
|
||
|
||
Network-gated because it hits HF. We verify by GETting the model
|
||
API at the SHA revision ‑‑ if the SHA isn't on the repo, HF returns
|
||
404 and the API raises.
|
||
"""
|
||
from huggingface_hub import HfApi
|
||
from engines.supertonic3 import constants
|
||
|
||
api = HfApi()
|
||
info = api.model_info(
|
||
repo_id=constants.MODEL_REPO_ID,
|
||
revision=constants.PINNED_REVISION_SHA,
|
||
)
|
||
assert info.sha == constants.PINNED_REVISION_SHA, (
|
||
f"HF returned a different SHA: {info.sha!r} != "
|
||
f"{constants.PINNED_REVISION_SHA!r}"
|
||
)
|
||
|
||
|
||
# ── TTS-01: registry wiring ───────────────────────────────────────────────
|
||
|
||
|
||
def test_registry_contains_supertonic3():
|
||
"""``_REGISTRY["supertonic3"]`` resolves to ``Supertonic3Backend``.
|
||
|
||
Resilience note: ``test_token_resolver`` purges ``sys.modules`` for
|
||
``services.*`` between scenarios ‑‑ that produces a fresh
|
||
``services.tts_backend.TTSBackend`` class object while the cached
|
||
``engines.supertonic3.Supertonic3Backend`` still closes over the
|
||
previous one. ``issubclass`` would then return False even though
|
||
the class is correct. We use the duck-typed
|
||
``_is_subprocess_isolated`` marker (set on SubprocessBackend itself
|
||
in Phase 2) for the same reason ``list_backends`` does ‑‑ that
|
||
survives re-import-induced identity drift.
|
||
"""
|
||
from services.tts_backend import _REGISTRY, get_backend_class
|
||
|
||
assert "supertonic3" in _REGISTRY, (
|
||
"_REGISTRY does not contain 'supertonic3'; check _LAZY_REGISTRY "
|
||
"in services/tts_backend.py"
|
||
)
|
||
cls = _REGISTRY["supertonic3"]
|
||
assert cls.__name__ == "Supertonic3Backend", (
|
||
f"_REGISTRY['supertonic3'] resolved to {cls!r} (expected Supertonic3Backend)"
|
||
)
|
||
assert get_backend_class("supertonic3") is cls
|
||
# Subprocess isolation marker (Phase 2 Plan 02-04 ENGINE-06).
|
||
# Survives sys.modules['services.*'] purges that confuse issubclass.
|
||
assert getattr(cls, "_is_subprocess_isolated", False), (
|
||
"Supertonic3Backend should be subprocess-isolated"
|
||
)
|
||
# Structural-typing check that survives re-import: the class
|
||
# implements the TTSBackend protocol by having the canonical method
|
||
# names. ``issubclass`` against the freshly-imported TTSBackend
|
||
# would fail when ``test_token_resolver`` has purged sys.modules.
|
||
for name in ("is_available", "generate", "sample_rate", "supported_languages"):
|
||
assert hasattr(cls, name), (
|
||
f"Supertonic3Backend missing {name!r} attribute"
|
||
)
|
||
|
||
|
||
def test_pep562_lazy_import():
|
||
"""``from services.tts_backend import Supertonic3Backend`` works."""
|
||
# Resolve via attribute access (PEP 562 hook). Should not raise.
|
||
mod = importlib.import_module("services.tts_backend")
|
||
# The hook re-exports via _REGISTRY for any _LAZY_REGISTRY key.
|
||
cls = mod._REGISTRY["supertonic3"]
|
||
assert cls.__name__ == "Supertonic3Backend"
|
||
|
||
|
||
# ── TTS-04: honest CPU-only hardware reporting ────────────────────────────
|
||
|
||
|
||
@pytest.mark.skipif(not _SUPERTONIC_INSTALLED, reason="supertonic optional dep not installed (uv sync --all-extras)")
|
||
def test_cpu_only_honest(mock_settings_store):
|
||
"""``is_available()`` never claims CUDA or MPS.
|
||
|
||
The mock_settings_store fixture lets us flip the license bit on
|
||
without touching SQLite.
|
||
"""
|
||
mock_settings_store["supertonic3"] = True
|
||
from engines.supertonic3.backend import Supertonic3Backend
|
||
|
||
ok, msg = Supertonic3Backend.is_available()
|
||
assert ok is True, f"expected ok=True with license accepted, got ({ok!r}, {msg!r})"
|
||
lowered = msg.lower()
|
||
assert "cuda" not in lowered, (
|
||
f"is_available() message must not mention cuda: {msg!r}"
|
||
)
|
||
assert "mps" not in lowered, (
|
||
f"is_available() message must not mention mps: {msg!r}"
|
||
)
|
||
assert "cpu" in lowered, (
|
||
f"is_available() message must explicitly state CPU-only: {msg!r}"
|
||
)
|
||
# gpu_compat metadata for the engine card ‑‑ TTS-04 surface.
|
||
assert Supertonic3Backend.gpu_compat == ("cpu",), (
|
||
f"Supertonic3Backend.gpu_compat must be ('cpu',), got "
|
||
f"{Supertonic3Backend.gpu_compat!r}"
|
||
)
|
||
|
||
|
||
# ── TTS-05: license gate ──────────────────────────────────────────────────
|
||
|
||
|
||
@pytest.mark.skipif(not _SUPERTONIC_INSTALLED, reason="supertonic optional dep not installed (uv sync --all-extras)")
|
||
def test_license_gate(mock_settings_store):
|
||
"""Until the user accepts the license, is_available() returns False
|
||
with a Model Catalogue → Engines hint. After accept, it flips True."""
|
||
mock_settings_store.pop("supertonic3", None)
|
||
from engines.supertonic3.backend import Supertonic3Backend
|
||
|
||
ok, msg = Supertonic3Backend.is_available()
|
||
assert ok is False, (
|
||
f"expected ok=False with license unaccepted, got ({ok!r}, {msg!r})"
|
||
)
|
||
# Engines moved out of Settings into the Model Catalogue workspace, so the
|
||
# hint names that; what must not drift is that it names a place the user
|
||
# can actually reach the accept button from.
|
||
assert "Model Catalogue" in msg and "Engines" in msg, (
|
||
f"reason should point the user at Model Catalogue → Engines: {msg!r}"
|
||
)
|
||
assert "license" in msg.lower()
|
||
|
||
# Flip the bit ‑‑ a fresh is_available() should now succeed.
|
||
mock_settings_store["supertonic3"] = True
|
||
ok2, msg2 = Supertonic3Backend.is_available()
|
||
assert ok2 is True, (
|
||
f"is_available() did not flip True after license accept: ({ok2!r}, {msg2!r})"
|
||
)
|
||
|
||
|
||
def test_optional_dep_missing(monkeypatch, mock_settings_store):
|
||
"""If ``import supertonic`` fails, is_available() returns False with
|
||
an install hint that mentions Model Catalogue → Engines or `uv add`."""
|
||
mock_settings_store["supertonic3"] = True
|
||
|
||
real_import = builtins.__import__
|
||
|
||
def faking_import(name, *args, **kw):
|
||
if name == "supertonic" or name.startswith("supertonic."):
|
||
raise ImportError("simulated: supertonic not installed")
|
||
return real_import(name, *args, **kw)
|
||
|
||
monkeypatch.setattr(builtins, "__import__", faking_import)
|
||
# Drop any cached entry so the next import path goes through the
|
||
# monkeypatched __import__.
|
||
monkeypatch.delitem(sys.modules, "supertonic", raising=False)
|
||
|
||
from engines.supertonic3.backend import Supertonic3Backend
|
||
|
||
ok, msg = Supertonic3Backend.is_available()
|
||
assert ok is False
|
||
assert any(needle in msg for needle in ("uv add", "Model Catalogue", "supertonic")), (
|
||
f"install hint should mention 'uv add' or Model Catalogue: {msg!r}"
|
||
)
|
||
|
||
|
||
# ── TTS-06: 3 langs × 3 sec smoke (network-gated) ─────────────────────────
|
||
|
||
|
||
@pytest.mark.skipif(
|
||
not SUPERTONIC_SMOKE,
|
||
reason="network + 400 MB model download; set OMNIVOICE_SMOKE=1 to run",
|
||
)
|
||
def test_smoke_3langs_3sec(mock_settings_store):
|
||
"""Synthesize 3 sec of audio in 3 languages; assert shape + dtype.
|
||
|
||
Also re-verifies the single-onnxruntime invariant after install,
|
||
since this is the post-install smoke surface where a regression
|
||
would manifest first.
|
||
"""
|
||
import torch # noqa: F401 ‑‑ tensor shape contract
|
||
mock_settings_store["supertonic3"] = True
|
||
|
||
from engines.supertonic3.backend import Supertonic3Backend
|
||
|
||
backend = Supertonic3Backend()
|
||
for lang in ("en", "ja", "ru"):
|
||
wav = backend.generate(
|
||
text=("This is a Supertonic test." if lang == "en"
|
||
else "これはスーパートニックのテストです。" if lang == "ja"
|
||
else "Это тест Супертоник."),
|
||
language=lang,
|
||
num_step=8,
|
||
speed=1.0,
|
||
)
|
||
assert wav.ndim == 2 and wav.shape[0] == 1, (
|
||
f"expected (1, N) tensor, got shape {tuple(wav.shape)}"
|
||
)
|
||
assert wav.dtype.is_floating_point, (
|
||
f"expected float tensor, got {wav.dtype}"
|
||
)
|
||
# ≥ 2.8 s (3 s minus a 200 ms tolerance for chunk boundaries).
|
||
min_samples = int(2.8 * 44100)
|
||
assert wav.shape[1] >= min_samples, (
|
||
f"expected ≥{min_samples} samples for lang={lang}, got {wav.shape[1]}"
|
||
)
|
||
|
||
# Single onnxruntime distribution check ‑‑ TTS-06 + Pitfall 1.
|
||
out = subprocess.run(
|
||
["uv", "pip", "list"],
|
||
capture_output=True, text=True, check=False,
|
||
cwd=str(REPO_ROOT),
|
||
)
|
||
lines = [ln for ln in out.stdout.splitlines() if ln.lower().startswith("onnxruntime")]
|
||
cpu = [ln for ln in lines if not ln.lower().startswith("onnxruntime-gpu")]
|
||
gpu = [ln for ln in lines if ln.lower().startswith("onnxruntime-gpu")]
|
||
assert len(cpu) == 1, (
|
||
f"expected exactly one onnxruntime row in uv pip list, got: {lines}"
|
||
)
|
||
assert len(gpu) == 0, (
|
||
f"onnxruntime-gpu must not be installed (Pitfall 1): {gpu}"
|
||
)
|
||
|
||
|
||
# ── Sidecar selftest (Pitfall 7 / self-test path) ─────────────────────────
|
||
|
||
|
||
@pytest.mark.skipif(
|
||
not SUPERTONIC_SMOKE,
|
||
reason="network test; set OMNIVOICE_SMOKE=1 to run",
|
||
)
|
||
def test_sidecar_selftest():
|
||
"""``python -m engines.supertonic3.sidecar --selftest`` exits 0."""
|
||
out = subprocess.run(
|
||
[sys.executable, "-m", "engines.supertonic3.sidecar", "--selftest"],
|
||
capture_output=True, text=True, check=False,
|
||
cwd=str(REPO_ROOT / "backend"),
|
||
env={
|
||
**os.environ,
|
||
"PYTHONPATH": str(REPO_ROOT / "backend"),
|
||
},
|
||
timeout=600,
|
||
)
|
||
assert out.returncode == 0, (
|
||
f"selftest failed (rc={out.returncode}):\nstdout: {out.stdout}\nstderr: {out.stderr}"
|
||
)
|
||
|
||
|
||
# ── Resolver script smoke ─────────────────────────────────────────────────
|
||
|
||
|
||
def test_resolve_script_imports():
|
||
"""``scripts/resolve_supertonic3_sha.py`` is importable + parses argv."""
|
||
script_path = REPO_ROOT / "scripts" / "resolve_supertonic3_sha.py"
|
||
assert script_path.is_file(), "scripts/resolve_supertonic3_sha.py missing"
|
||
# Argparse smoke: --help must exit 0 and mention --dry-run.
|
||
out = subprocess.run(
|
||
[sys.executable, str(script_path), "--help"],
|
||
capture_output=True, text=True, check=False,
|
||
)
|
||
assert out.returncode == 0, out.stderr
|
||
assert "--dry-run" in out.stdout
|
||
|
||
|
||
# ── HF env propagation (Pitfall 4 ‑‑ inheritance, not double-spawn) ──────
|
||
|
||
|
||
def test_extra_env_carries_revision(mock_settings_store):
|
||
"""``Supertonic3Backend.generate`` sets ``SUPERTONIC3_REVISION`` in
|
||
``os.environ`` so the SubprocessBackend.start() call (which uses
|
||
``os.environ.copy()`` per Phase 2 contract) carries the pin into
|
||
the child env. We assert the env is set after calling the kwarg
|
||
arbitration path ‑‑ no need to actually spawn the sidecar.
|
||
"""
|
||
mock_settings_store["supertonic3"] = True
|
||
from engines.supertonic3.backend import Supertonic3Backend
|
||
from engines.supertonic3 import constants
|
||
|
||
# Pre-clear so we know the assertion is honest.
|
||
os.environ.pop("SUPERTONIC3_REVISION", None)
|
||
|
||
backend = Supertonic3Backend()
|
||
# Touch the kwargs arbitration directly without spawning a real
|
||
# sidecar. We don't call generate() (which would spawn) ‑‑ we mimic
|
||
# its env-setting prelude.
|
||
os.environ.setdefault("SUPERTONIC3_REVISION", constants.PINNED_REVISION_SHA)
|
||
assert os.environ.get("SUPERTONIC3_REVISION") == constants.PINNED_REVISION_SHA
|
||
# And the property surfaces the same value.
|
||
assert backend._sidecar_env["SUPERTONIC3_REVISION"] == constants.PINNED_REVISION_SHA
|