Files
skills/tests/test_hub_box_heads.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

95 lines
4.7 KiB
Python

from __future__ import annotations
import json
import re
import subprocess
import unittest
from hub_support import HUB
TEMPLATES = HUB / "templates"
MODULES = ["page-constants.js", "page-reveal.js", "page-dom.js"]
VIEWS = {
"page-match.js": "Match",
"page-tasks.js": "Tasks",
"page-resources.js": "Resources",
"page-artifacts.js": "Artifacts",
"page-graph-charts.js": "Agents",
"page-firewall.js": "Controls",
}
PROBE = r"""
const fs = require("fs");
const vm = require("vm");
const [dir, names] = [process.argv[1], JSON.parse(process.argv[2])];
class El {
constructor(tag) { Object.assign(this, {tag, children: [], attrs: {}, dataset: {}, style: {}}); }
setAttribute(key, value) { this.attrs[key] = String(value); }
getAttribute(key) { return Object.hasOwn(this.attrs, key) ? this.attrs[key] : null; }
append(...nodes) { this.children.push(...nodes); }
addEventListener() {}
}
const document = {
currentScript: null, body: new El("body"),
getElementById: () => Object.assign(new El("div"), {textContent: "[]"}),
createElement: (tag) => new El(tag), createElementNS: (ns, tag) => new El(tag),
};
const context = {
console, document, JSON, Math, Date, Intl, Promise, Set, Map, Number, String, Array, Object, RegExp, Boolean, Error,
Node: El, Element: El, HTMLElement: El,
window: {location: {hash: ""}, setTimeout: () => 0, matchMedia: () => ({matches: false})},
state: {inbox: [], radio: []}, ui: {}, settings: {},
};
const source = names.map((name) => fs.readFileSync(`${dir}/${name}`, "utf8")).join("\n");
const probe = `
const title = h("strong", {class: "box-title"}, "Match");
const count = h("span", {}, "2 cards wait");
const button = h("button", {type: "button"}, "Tasks");
const band = boxHead("Match", "task-toolbar", title, count, null, button);
const plain = boxHead("Resources", "", button);
const holding = boxHead("Agents", "", h("div", {role: "toolbar", "aria-label": "Agents tools"}, button));
JSON.stringify({
band: {tag: band.tag, attrs: band.attrs, order: band.children.map((child) => child.tag + ":" + (child.children[0] || ""))},
plain: plain.attrs.class, holding: holding.attrs.role,
});
`;
console.log(vm.runInNewContext(`${source}\n${probe}`, context));
"""
class TestBoxHeads(unittest.TestCase):
def test_the_band_helper_renders_its_label_classes_and_children_in_order_and_never_nests_a_toolbar(self):
done = subprocess.run(["node", "-e", PROBE, str(TEMPLATES), json.dumps(MODULES)], capture_output=True, text=True, timeout=60, check=False)
self.assertEqual(done.returncode, 0, done.stderr)
out = json.loads(done.stdout)
self.assertEqual(out["band"]["tag"], "div")
self.assertEqual(out["band"]["attrs"], {"class": "box-head task-toolbar", "role": "toolbar", "aria-label": "Match"})
self.assertEqual(out["band"]["order"], ["strong:Match", "span:2 cards wait", "button:Tasks"])
self.assertEqual((out["plain"], out["holding"]), ("box-head", "group"))
def test_every_view_builds_its_controls_with_the_one_band_helper(self):
helpers = [name for name in sorted(path.name for path in TEMPLATES.glob("*.js")) if re.search(r"\bconst boxHead\b|\bfunction boxHead\b", (TEMPLATES / name).read_text(encoding="utf-8"))]
self.assertEqual(helpers, ["page-dom.js"])
for name, label in VIEWS.items():
with self.subTest(view=name):
self.assertIn(f'boxHead("{label}"', (TEMPLATES / name).read_text(encoding="utf-8"))
def test_no_template_keeps_a_separate_controls_card(self):
for path in sorted(TEMPLATES.glob("*.js")):
with self.subTest(file=path.name):
self.assertNotIn("card controls", path.read_text(encoding="utf-8"))
def test_the_band_sits_on_the_box_edge_through_the_main_padding_variables(self):
page = (TEMPLATES / "index.html.j2").read_text(encoding="utf-8")
self.assertRegex(page, r"main \{ --main-pad: var\(--sp-5\); --main-top: var\(--main-pad\);[^}]*padding: var\(--main-top\) var\(--main-pad\)")
self.assertRegex(page, r"\.box-head \{[^}]*margin: calc\(-1 \* var\(--main-top\)\) calc\(-1 \* var\(--main-pad\)\) 0;")
self.assertIn("--main-top: var(--sp-3)", (TEMPLATES / "style-ui.css").read_text(encoding="utf-8"))
def test_the_match_card_bar_flows_from_the_outer_edge_into_the_card(self):
css = (TEMPLATES / "style-match.css").read_text(encoding="utf-8")
self.assertRegex(css, r"\.match-card\.front \{[^}]*border-top-width: 0;")
self.assertRegex(css, r"\.match-card\.front::before \{[^}]*inset: 0 0 auto;[^}]*height: 22px; background: var\(--bar\); mask-image: linear-gradient\(180deg, #000 0px 4px, transparent 22px\);")
if __name__ == "__main__":
unittest.main()