2026-08-24 03:08:56 -03:00
|
|
|
"""Executable and static gates for the vanilla HUX Wave A runtime bridge."""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
2026-08-24 05:22:01 -03:00
|
|
|
from hux_node_gate import run_node_coverage
|
|
|
|
|
|
2026-08-24 03:08:56 -03:00
|
|
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
RUNTIME = ROOT / "dockerfiles" / "hermes-webui-hux" / "runtime"
|
|
|
|
|
|
|
|
|
|
|
2026-08-24 05:22:01 -03:00
|
|
|
|
2026-08-24 03:08:56 -03:00
|
|
|
def test_hux_wave_a_vanilla_runtime_and_coverage():
|
2026-08-24 05:22:01 -03:00
|
|
|
run_node_coverage(
|
|
|
|
|
[
|
|
|
|
|
"dockerfiles/hermes-webui-hux/runtime/wave_a_contract.js",
|
|
|
|
|
"dockerfiles/hermes-webui-hux/runtime/wave_a_activity_memory.js",
|
|
|
|
|
],
|
2026-08-24 03:08:56 -03:00
|
|
|
[
|
|
|
|
|
"testing/tests/test_hermes_hux_ui_runtime_wave_a.js",
|
|
|
|
|
],
|
2026-08-24 05:22:01 -03:00
|
|
|
{"branches": 95, "functions": 95, "lines": 95},
|
|
|
|
|
strip_types=False,
|
2026-08-24 03:08:56 -03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_wave_a_runtime_is_dependency_free_scoped_and_not_live_wired():
|
|
|
|
|
contract = (RUNTIME / "wave_a_contract.js").read_text(encoding="utf-8")
|
|
|
|
|
renderer = (RUNTIME / "wave_a_activity_memory.js").read_text(encoding="utf-8")
|
|
|
|
|
styles = (RUNTIME / "wave_a_activity_memory.css").read_text(encoding="utf-8")
|
|
|
|
|
combined = contract + renderer
|
|
|
|
|
assert "require('../foundation.js')" in contract
|
|
|
|
|
assert "require('../shell.js')" in renderer
|
|
|
|
|
assert "/conversations/${conversationId}/events?after_seq=0&limit=200" in renderer
|
|
|
|
|
assert "context.client.request('/memory')" in renderer
|
|
|
|
|
assert "'If-Match': String(item.revision)" in renderer
|
|
|
|
|
assert "'Idempotency-Key': idempotencyKey" in renderer
|
|
|
|
|
assert "credentials: 'same-origin'" in contract and "cache: 'no-store'" in contract
|
|
|
|
|
assert "item.detail" not in renderer
|
|
|
|
|
assert "raw.detail" not in renderer
|
|
|
|
|
assert "dangerouslySetInnerHTML" not in combined and "innerHTML" not in combined
|
|
|
|
|
for forbidden in (
|
|
|
|
|
"React",
|
|
|
|
|
"lucide",
|
|
|
|
|
"tailwind",
|
|
|
|
|
"localStorage",
|
|
|
|
|
"sessionStorage",
|
|
|
|
|
"indexedDB",
|
|
|
|
|
"document.cookie",
|
|
|
|
|
):
|
|
|
|
|
assert forbidden not in combined
|
|
|
|
|
assert ".hux-wave-a" in styles
|
|
|
|
|
assert "body" not in styles and ":root" not in styles
|
|
|
|
|
assert "prefers-reduced-motion" in styles
|
|
|
|
|
dockerfile = (ROOT / "dockerfiles/Dockerfile.hermes-webui").read_text(encoding="utf-8")
|
|
|
|
|
assert "COPY dockerfiles/hermes-webui-hux/runtime/wave_a_contract.js" in dockerfile
|
|
|
|
|
assert "COPY dockerfiles/hermes-webui-hux/runtime/wave_a_activity_memory.js" in dockerfile
|
|
|
|
|
bootstrap = (ROOT / "dockerfiles/hermes-webui-hux/bootstrap.js").read_text(encoding="utf-8")
|
|
|
|
|
assert "root.HermesHuxWaveA.createWaveARuntime" in bootstrap
|
|
|
|
|
assert "normalizeContext(sessionReader())" in bootstrap
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_wave_a_runtime_files_remain_bounded_and_isolated():
|
|
|
|
|
sources = {
|
|
|
|
|
RUNTIME / "wave_a_activity_memory.css",
|
|
|
|
|
RUNTIME / "wave_a_activity_memory.js",
|
|
|
|
|
RUNTIME / "wave_a_contract.js",
|
|
|
|
|
}
|
|
|
|
|
assert all(path.is_file() for path in sources)
|
|
|
|
|
for path in sources:
|
|
|
|
|
assert len(path.read_text(encoding="utf-8").splitlines()) <= 500
|