Files
skills/tests/e2e/test_speak_card_e2e.py
T
Kevin Veen-BirkenbachandClaude Opus 5.5 0fad1bfae3 feat: hub and skills requirements 032 to 063
Hub: send in the field (032), coherent speak box (033), stream head band (034), Match at full width with its pile (035, 036), Home without the outer box (037), badge to Match (038), rejects that survive a changed or withdrawn card (039), the release card (040), code marks in the review diff (041), why Deny is off (042), the undo window clock (043), widgets without inner boxes (044), the Artifacts head on one line (045), accepting a red gate's risk (046), one code box (047), done rows greyed and folded (048), one control height (049), menus that stay open (050), radio settings in the Device card (051), bubbles beside the modes (052), agent settings on every face and name (053), pin only by menu (054), WASD in Match (055), the flowing card edge (056), Schedules in Controls (057) and the hub poll cost (059).

Skills: the coach leaves for its own repository kevinveenbirkenbach/coach (058; test_install pins its four skills in skills-lock.json and stays red until that repository is published and pinned), hooks and timers start fewer processes (060), council files on hot paths stay bounded and mirror by marker instead of mtime (061), scripts and hooks hand agents less output (062), and block.py builds the commit table and message block in one run (063). Requirement documents 032 to 063 with their implementation amendments.

MEDUSA false positives accepted after kvb-think-criticize (36 lines): MM-SCAN-058 (pla inside replace or plan), JB-SCAN-616/641 (the local clip helper), CODEGEN-SCAN-001 (drop-in paths), CGS-SCAN-029 (systemctl argv from constants), CGS-SCAN-040 (runner poll loop), FLA-SCAN-055 (feedback), WM-SCAN-354, AI-BACKDOOR-006, GENAI-SCAN-1270, B604 (runner shell path for passkey-verified commands), TC004, EXA002, EXA006, EXA010 and WEB-SSRF.

🎯 Fix: 92 %
💥 Break: 8 %
💸 Tokens: 89 %
⏱️ Velocity: –
🛡️ Security: ~100 %
🏆 Score: 95
🚦 Gate: ⛔ break 8 % > 5

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 08:44:15 +00:00

148 lines
8.0 KiB
Python

from __future__ import annotations
import json
import os
import shutil
import sys
import time
import unittest
from pathlib import Path
HERE = Path(__file__).resolve().parent
sys.path[:0] = [str(HERE.parent), str(HERE)]
import hub_e2e_kit as base
import test_workbench_w4_e2e as w4
from kvb_orchestrator import skill_scripts
OUT = Path(os.environ.get("E2E_OUT", "/tmp/speak-card-shots"))
HINTS = ("Post arrives at the end of the turn.", "Your passkey signs every message.")
CARD = """
const card = () => document.querySelector("#radio-spot .radio-speak");
const form = () => card().querySelector("form.composer");
const toggle = () => form().querySelector(".mayday-toggle");
const answer = async (yes) => {
toggle().click();
const box = await until(() => form().querySelector(".mayday-confirm"), 4000);
if (!box) {
return null;
}
const question = text(box.querySelector("p"));
all("button", box).find((node) => text(node) === (yes ? yes : "Cancel")).click();
return question;
};
const posted = [];
const send = window.fetch.bind(window);
window.fetch = (path, init) => {
if (/^\\/api\\/(board|messages)/.test(String(path))) {
posted.push(String(path));
}
return send(path, init);
};
"""
RAISE = """(async () => {@HELPERS@@CARD@
if (!(await screenShown(8000)) || !(await until(card, 8000))) {
return {error: text(document.getElementById("main"))};
}
await sleep(400);
const foot = toggle().parentElement;
const radius = (node) => getComputedStyle(node).borderTopLeftRadius;
const layout = {
hints: @HINTS@.filter((line) => text(card()).includes(line)),
channels: all("select option", form()).slice(0, 6).map((option) => [option.value, Boolean(option.title)]),
mayday: all("select option", form()).some((option) => option.value === "mayday"),
next: Boolean(toggle().previousElementSibling && toggle().previousElementSibling.matches(".ptt-split")),
face: [text(toggle()), toggle().getAttribute("aria-pressed")],
cards: all(".card", card()).length,
radius: [radius(card()), radius(form().querySelector(".composer-grid")), radius(form().querySelector("textarea").closest(".mic-frame"))],
fits: foot.scrollWidth <= foot.clientWidth + 1 && foot.getBoundingClientRect().right <= card().getBoundingClientRect().right + 1,
wide: document.documentElement.scrollWidth > innerWidth + 1,
};
const field = form().querySelector("textarea");
field.value = "disk full @WIDTH@";
field.dispatchEvent(new Event("input", {bubbles: true}));
const shown = new Set(all("#toasts .toast"));
const declined = await answer(false);
await sleep(600);
const quiet = posted.slice();
const asked = await answer("Send mayday");
const toast = await until(() => all("#toasts .toast").filter((node) => !shown.has(node)).map(text).find((line) => line.includes(" to all")), 15000);
return {layout, declined, quiet, asked, toast, left: field.value, violations: window.e2eViolations || null};
})()"""
CANCEL = """(async () => {@HELPERS@@CARD@
if (!(await screenShown(8000)) || !(await until(() => card() && toggle().getAttribute("aria-pressed") === "true", 8000))) {
return {error: text(document.getElementById("main"))};
}
const face = [text(toggle()), toggle().getAttribute("aria-pressed"), toggle().title];
const shown = new Set(all("#toasts .toast"));
const asked = await answer("Cancel mayday");
const toast = await until(() => all("#toasts .toast").filter((node) => !shown.has(node)).map(text).find((line) => line.startsWith("Cancel mayday")), 15000);
return {face, asked, toast, posted};
})()"""
IDLE = """(async () => {@HELPERS@@CARD@
await screenShown(8000);
await until(card, 8000);
return {face: [text(toggle()), toggle().getAttribute("aria-pressed")]};
})()"""
def probe(template: str, **names: str) -> str:
fills = {"@HELPERS@": base.HELPERS, "@CARD@": CARD, "@HINTS@": json.dumps(HINTS)}
fills.update({f"@{key.upper()}@": value for key, value in names.items()})
for key, value in fills.items():
template = template.replace(key, value)
return template
@unittest.skipUnless(shutil.which(os.environ.get("CHROMIUM", "chromium")), "no Chromium")
class TestSpeakCard(base.OrchestratorE2ECase):
def setUp(self):
super().setUp()
OUT.mkdir(parents=True, exist_ok=True)
(self.council / "radio-silence.json").unlink()
self.local = f"http://localhost:{self.port}/"
def steps(self, template: str, name: str) -> list[dict]:
return [{"width": width, "height": height, "url": f"{self.local}?{width}-{name}#stream/radio", "wait": 1200, "probe": probe(template, width=str(width)), "shot": self.shot(f"{width}-speak-{name}")} for width, height in base.WIDTHS]
def test_chromium_raises_and_cancels_a_mayday_from_the_toggle_beside_ptt(self):
raised = self.drive(self.steps(RAISE, "raise"), self.authenticator(), init=w4.GUARD)
(OUT / "chromium-raise.json").write_text(json.dumps(raised, indent=1), encoding="utf-8")
self.assertEqual(raised["errors"], [])
ask = "Send a mayday to all? All agents pause writing steps until you cancel it."
for result, (width, _) in zip(raised["results"], base.WIDTHS, strict=True):
with self.subTest(step="raise", width=width):
self.assertNotIn("error", result, result)
layout = result["layout"]
self.assertEqual((layout["hints"], layout["mayday"], layout["next"], layout["face"], layout["cards"]), ([], False, True, ["MAYDAY", "false"], 0), layout)
self.assertEqual([value for value, _ in layout["channels"]], ["post", "call", "newsletter", "broadcast", "pan-pan", "security"], layout)
self.assertFalse(any(titled for _, titled in layout["channels"]), layout)
self.assertEqual(layout["radius"], ["14px", "0px", "10px"], layout)
self.assertEqual((layout["fits"], layout["wide"]), (True, False), layout)
self.assertEqual((result["declined"], result["quiet"], result["asked"]), (ask, [], ask), result)
self.assertTrue((result["toast"] or "").startswith("Mayday to all: sent$ radio.py send mayday"), result)
self.assertEqual((result["left"], w4.quiet(result["violations"])), ("", []), result)
sent = [args for script, args in self.scripts.calls if script == skill_scripts.RADIO]
self.assertEqual([args[:2] for args in sent], [["send", "mayday"]] * len(base.WIDTHS))
for args, (width, _) in zip(sent, base.WIDTHS, strict=True):
self.assertTrue(args[-1].endswith(f"disk full {width}"), args)
self.scripts.calls.clear()
(self.council / "radio-silence.json").write_text(json.dumps({"since": time.time() - 30, "until": time.time() + 3600, "by": "Operator", "text": "disk full"}), encoding="utf-8")
cancelled = self.drive(self.steps(CANCEL, "cancel"), {**self.authenticator(), "signCount": len(base.WIDTHS)}, init=w4.GUARD)
(OUT / "chromium-cancel.json").write_text(json.dumps(cancelled, indent=1), encoding="utf-8")
self.assertEqual(cancelled["errors"], [])
for result, (width, _) in zip(cancelled["results"], base.WIDTHS, strict=True):
with self.subTest(step="cancel", width=width):
self.assertNotIn("error", result, result)
self.assertEqual(result["face"][:2], ["Cancel mayday", "true"], result)
self.assertEqual((result["asked"], result["posted"]), ("Lift the radio silence of the active mayday?", ["/api/board/sign", "/api/board/clear-mayday"]), result)
self.assertTrue((result["toast"] or "").startswith("Cancel mayday: done"), result)
self.assertEqual(self.scripts.calls, [(skill_scripts.RADIO, ["clear", "--force", "--session", "Operator"])] * len(base.WIDTHS))
(self.council / "radio-silence.json").unlink()
idle = self.drive(self.steps(IDLE, "idle"), None, init=w4.GUARD)
self.assertEqual([result["face"] for result in idle["results"]], [["MAYDAY", "false"]] * len(base.WIDTHS))
if __name__ == "__main__":
unittest.main()