Standalone per-card browser model/security/view modules for HUX-01..10 plus node+pytest suites that read the hux.v1 contract schemas directly. Reconciled drift found on integration: the activity model now accepts all 32 hux.event.v1 kinds (delegation.*, memory.suppressed, memory.retrieval_removed, budget.exhausted, side_effect.*), the autonomy model carries the external_side_effect capability, and the foundation boundary test now asserts the shipped static HUX surface exists on disk and that images never bake activated HUX_FLAGS. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BvMSXH8VH2tMWXanb8SJdf
84 lines
3.1 KiB
Python
84 lines
3.1 KiB
Python
"""Executable and static quality gates for the isolated HUX-06 frontend."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
MODES = ROOT / "dockerfiles" / "hermes-webui-hux" / "modes"
|
|
|
|
|
|
def test_hux_modes_model_node_suite_and_coverage():
|
|
"""Mode intent validation is covered above the repository threshold."""
|
|
|
|
result = subprocess.run(
|
|
[
|
|
"node",
|
|
"--test",
|
|
"--experimental-strip-types",
|
|
"--experimental-test-coverage",
|
|
"--test-coverage-lines=95",
|
|
"--test-coverage-functions=95",
|
|
"--test-coverage-include=dockerfiles/hermes-webui-hux/modes/model.ts",
|
|
"testing/tests/test_hermes_hux_ui_modes.mjs",
|
|
],
|
|
cwd=ROOT,
|
|
check=False,
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=30,
|
|
)
|
|
assert result.returncode == 0, result.stdout + result.stderr
|
|
|
|
|
|
def test_hux_modes_component_is_flagged_accessible_and_provider_neutral():
|
|
"""Static UI guardrails preserve keyboard access and neutral routing."""
|
|
|
|
component = (MODES / "FriendlyModeSelector.tsx").read_text(encoding="utf-8")
|
|
model = (MODES / "model.ts").read_text(encoding="utf-8")
|
|
styles = (MODES / "styles.css").read_text(encoding="utf-8")
|
|
assert "if (!enabled) return null" in component
|
|
assert "friendlyModesEnabled(flags)" in component
|
|
assert "<fieldset" in component and "<legend" in component
|
|
assert 'type="radio"' in component and "aria-describedby" in component
|
|
assert "<details" in component and "<summary" in component
|
|
assert "<select" in component and 'aria-live="polite"' in component
|
|
assert "Automatic — use all allowed pools" in component
|
|
assert "codex" in model and "claude" in model and "local" in model
|
|
assert "preferred_provider" not in model
|
|
assert "default_provider" not in model
|
|
assert "dangerouslySetInnerHTML" not in component
|
|
assert ".hux-modes" in styles
|
|
assert "body" not in styles and ":root" not in styles
|
|
assert "focus-visible" in styles and "prefers-reduced-motion" in styles
|
|
|
|
|
|
def test_hux_modes_matches_contract_and_stays_inert_and_bounded():
|
|
"""HUX-06 uses the declared schema without entering the live build."""
|
|
|
|
schema = json.loads(
|
|
(ROOT / "services/hermes/contracts/hux/mode.schema.json").read_text(
|
|
encoding="utf-8"
|
|
)
|
|
)
|
|
model = (MODES / "model.ts").read_text(encoding="utf-8")
|
|
assert schema["properties"]["schema"]["const"] == "hux.mode.v1"
|
|
for mode in schema["properties"]["mode"]["enum"]:
|
|
assert f'"{mode}"' in model
|
|
assert "hux.mode.v1" in model and "hux.v1" in model
|
|
assert {path.name for path in MODES.iterdir()} == {
|
|
"FriendlyModeSelector.tsx",
|
|
"index.ts",
|
|
"model.ts",
|
|
"styles.css",
|
|
"types.ts",
|
|
}
|
|
for path in MODES.iterdir():
|
|
assert len(path.read_text(encoding="utf-8").splitlines()) <= 500
|
|
assert "hermes-webui-hux/modes" not in (
|
|
ROOT / "dockerfiles/Dockerfile.hermes-webui"
|
|
).read_text(encoding="utf-8")
|