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
77 lines
3.0 KiB
Python
77 lines
3.0 KiB
Python
"""Executable and static quality gates for isolated HUX-02 memory controls."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
MEMORY = ROOT / "dockerfiles" / "hermes-webui-hux" / "memory"
|
|
|
|
|
|
def test_hux_memory_model_node_suite_and_coverage():
|
|
result = subprocess.run(
|
|
[
|
|
"node",
|
|
"--test",
|
|
"--experimental-strip-types",
|
|
"--experimental-test-coverage",
|
|
"--test-coverage-lines=95",
|
|
"--test-coverage-functions=95",
|
|
"--test-coverage-branches=95",
|
|
"--test-coverage-include=dockerfiles/hermes-webui-hux/memory/model.ts",
|
|
"--test-coverage-include=dockerfiles/hermes-webui-hux/memory/security.ts",
|
|
"--test-coverage-include=dockerfiles/hermes-webui-hux/memory/endpoints.ts",
|
|
"testing/tests/test_hermes_hux_ui_memory.mjs",
|
|
],
|
|
cwd=ROOT,
|
|
check=False,
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=30,
|
|
)
|
|
assert result.returncode == 0, result.stdout + result.stderr
|
|
|
|
|
|
def test_hux_memory_component_is_flagged_accessible_and_privacy_safe():
|
|
component = (MEMORY / "MemoryControlCenter.tsx").read_text(encoding="utf-8")
|
|
model = (MEMORY / "model.ts").read_text(encoding="utf-8")
|
|
endpoints = (MEMORY / "endpoints.ts").read_text(encoding="utf-8")
|
|
styles = (MEMORY / "styles.css").read_text(encoding="utf-8")
|
|
assert "if (!enabled) return null" in component
|
|
assert "workspace scope could not be verified" in component
|
|
assert "memoryControlEnabled(props.flags)" in component
|
|
assert all(name in model for name in ("FOUNDATION_FLAG", "PRIVACY_FLAG", "MEMORY_CONTROL_FLAG"))
|
|
assert 'aria-label="Memory ledger"' in component
|
|
assert 'role="status"' in component
|
|
assert "Suggest only" in component
|
|
assert "Edit as new entry" in component and "Delete & forget" in component
|
|
assert "View source message" in component
|
|
assert "This message" in component and "Block topic" in component
|
|
assert "dangerouslySetInnerHTML" not in component
|
|
assert "JSON.stringify" not in component
|
|
assert "source.id" not in component and "actor.id" not in component
|
|
assert "fetch(" not in endpoints and "axios" not in endpoints
|
|
assert ".hux-memory" in styles
|
|
assert "body" not in styles and ":root" not in styles
|
|
assert "prefers-reduced-motion" in styles
|
|
|
|
|
|
def test_hux_memory_sources_respect_size_and_isolated_scope():
|
|
sources = sorted(MEMORY.glob("*"))
|
|
assert {path.name for path in sources} == {
|
|
"MemoryControlCenter.tsx",
|
|
"endpoints.ts",
|
|
"index.ts",
|
|
"model.ts",
|
|
"security.ts",
|
|
"styles.css",
|
|
"types.ts",
|
|
}
|
|
for path in sources:
|
|
assert len(path.read_text(encoding="utf-8").splitlines()) <= 500
|
|
assert "dockerfiles/hermes-webui-hux/memory" not in (
|
|
ROOT / "dockerfiles" / "Dockerfile.hermes-agent"
|
|
).read_text(encoding="utf-8")
|