feat(orchestrator): explain gate chips through one glossary

glossary.js is the single source of the gate, branch and rule terms; ancestry, tree, artifacts, offices and rules render text chips from it with the explanation on hover, focus and Enter. Tests run once on unify/skills-20261114 after the merge (operator order 2026-11-14).

🎯 Fix: 80 %
💥 Break: 8 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 74
🚦 Gate: ⛔ fix 80 % < 90, break 8 % > 5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-14 21:32:03 +00:00
1 parent 48f26b678a
commit 9d8431049e
14 files changed
+400 -48

No files matched your search

+82 -14
View File
@@ -21,6 +21,12 @@ GATES_SPEC = importlib.util.spec_from_file_location("kvb_gates_for_e2e", REPO_RO
gates = importlib.util.module_from_spec(GATES_SPEC)
GATES_SPEC.loader.exec_module(gates)
KEPT_TIP = "0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b2c1d"
DONE_CHIPS = ["commit: test (inherited from main)", "merge: none (no rule)", "push: none (no rule)", "pr: e2e (own rule)"]
DONE_MARKS = [[action, level, inherited, words, inherited, True] for (action, level, inherited), words in zip([("commit", "test", True), ("merge", "none", True), ("push", "none", True), ("pr", "e2e", False)], DONE_CHIPS, strict=True)]
EXPLAINED = ["Gate actions", "Gate levels", "Where a level comes from", "Branch marks"]
CHIP_STATE = """
const chipState = (button) => [button.dataset.action, button.dataset.level, button.classList.contains("inherited"), button.getAttribute("aria-label"), getComputedStyle(button).borderTopStyle === "dashed", text(button) === button.getAttribute("aria-label") && button.title.split("\\n")[0] === text(button)];
"""
CLEAN_ALL = """(async () => {@HELPERS@@UNLABELLED@
const every = await until(() => document.querySelector('#main button[aria-label="Delete all merged"]'), 8000);
await until(() => document.querySelector("#main svg.ancestry"), 8000);
@@ -40,7 +46,7 @@ CLEAN_ALL = """(async () => {@HELPERS@@UNLABELLED@
return {before, token, store: store ? [store.title, store.getAttribute("aria-label")] : null, rows, outcome: outcome ? (outcome.dataset.cleanup ? "queued" : "unsigned") : null, tokenClick, labels,
wide: document.documentElement.scrollWidth > document.documentElement.clientWidth};
})()"""
ANCESTRY = """(async () => {@HELPERS@@UNLABELLED@
ANCESTRY = """(async () => {@HELPERS@@UNLABELLED@@CHIPS@
const svg = await until(() => document.querySelector('#main svg.ancestry[aria-label="Ancestry of github.com/me/demo"]'), 8000);
if (!svg) {
return {error: "no ancestry"};
@@ -49,9 +55,10 @@ ANCESTRY = """(async () => {@HELPERS@@UNLABELLED@
const edges = all("path.ancestry-edge", svg).map((edge) => [edge.dataset.parent, edge.dataset.child, edge.dataset.source, getComputedStyle(edge).strokeDasharray !== "none"]);
const marks = (branch) => {
const row = all("#main .branch-row").find((entry) => text(entry.querySelector(".branch-name strong")) === branch);
return row ? all(".gate-mark", row).map((button) => [button.dataset.action, button.dataset.level, button.classList.contains("inherited"), button.title, Number(getComputedStyle(button).opacity) < 1]) : null;
return row ? all(".gate-mark", row).map(chipState) : null;
};
return {nodes, edges, done: marks("feature/done"), main: marks("main"), unlabelled: unlabelled(document.getElementById("main")), wide: document.documentElement.scrollWidth > document.documentElement.clientWidth};
const inside = all("#main .gate-mark").every((chip) => chip.getBoundingClientRect().right <= document.documentElement.clientWidth + 1);
return {nodes, edges, done: marks("feature/done"), main: marks("main"), inside, unlabelled: unlabelled(document.getElementById("main")), wide: document.documentElement.scrollWidth > document.documentElement.clientWidth};
})()"""
STAGE = """(async () => {@HELPERS@
const svg = await until(() => document.querySelector("#main svg.ancestry"), 8000);
@@ -102,10 +109,10 @@ AGENTS = """(async () => {@HELPERS@@UNLABELLED@
const nodes = all("g.ancestry-node", fresh).map((node) => [node.dataset.kind, Number(node.dataset.generation), node.getBoundingClientRect().top]);
return {nodes, edges: all("path.ancestry-edge", fresh).length, list: all("#main .spawn-tree li").length, unlabelled: unlabelled(document.getElementById("main")), wide: document.documentElement.scrollWidth > document.documentElement.clientWidth};
})()"""
POPUP_GATES = """(async () => {@HELPERS@@UNLABELLED@
POPUP_GATES = """(async () => {@HELPERS@@UNLABELLED@@CHIPS@
const id = `branch:${@REPO@}\\u0000feature/done`;
const dialog = document.getElementById("popup");
const marks = (group) => all(".gate-mark", group).map((button) => [button.dataset.action, button.dataset.level, button.classList.contains("inherited"), button.title, Number(getComputedStyle(button).opacity) < 1]);
const marks = (group) => all(".gate-mark", group).map(chipState);
const shut = async () => {
(document.activeElement || document.body).dispatchEvent(new KeyboardEvent("keydown", {key: "Escape", bubbles: true}));
await until(() => !dialog.open, 4000);
@@ -152,10 +159,56 @@ POPUP_GATES = """(async () => {@HELPERS@@UNLABELLED@
}
return {shown, wide: document.documentElement.scrollWidth > document.documentElement.clientWidth};
})()"""
POPUP_EXPLAIN = """(async () => {@HELPERS@
const id = `branch:${@REPO@}\\u0000feature/done`;
const dialog = document.getElementById("popup");
await screenShown(8000);
const picker = await until(() => document.querySelector('#main select[aria-label="Repository"]'), 8000);
if (picker && picker.value !== @REPO@) {
picker.value = @REPO@;
picker.dispatchEvent(new Event("change", {bubbles: true}));
}
const target = await until(() => all("#main svg [data-pick]").find((node) => node.dataset.pick === id), 8000);
if (!target) {
return {error: text(document.getElementById("main"))};
}
target.dispatchEvent(new MouseEvent("click", {bubbles: true, cancelable: true}));
const group = await until(() => dialog.open && dialog.querySelector(".popup-box .gates"), 6000);
const explain = group ? dialog.querySelector(".popup-box details.gate-explain") : null;
if (!explain) {
return {error: "no gate chips or Explain in the popup", open: dialog.open};
}
explain.querySelector("summary").click();
await until(() => explain.open, 2000);
const box = dialog.querySelector(".popup-box");
const frame = box.getBoundingClientRect();
const inside = (node) => {
const rect = node.getBoundingClientRect();
return rect.left >= frame.left - 1 && rect.right <= frame.right + 1 && rect.right <= document.documentElement.clientWidth + 1;
};
const chips = all(".gate-mark", group);
const commit = group.querySelector('.gate-mark[data-action="commit"]');
commit.focus();
return {
chips: chips.map((chip) => [text(chip), chip.getAttribute("aria-label"), chip.title.split("\\n")[0], chip.tabIndex]),
inside: [...chips, explain].map(inside),
scrolls: [box, dialog.querySelector(".popup-body")].some((node) => node.scrollWidth > node.clientWidth + 1),
summary: [text(explain.querySelector("summary")), explain.open],
headings: all("h4", explain).map(text), terms: all("dt", explain).length,
focused: document.activeElement === commit,
wide: document.documentElement.scrollWidth > document.documentElement.clientWidth,
};
})()"""
KEYBOARD = """(async () => {@HELPERS@
const dialog = document.getElementById("popup");
const staged = await until(() => dialog.querySelector('.popup-box .gate-mark.pending[data-action="commit"]'), 4000);
const apply = document.querySelector('#main button[aria-label="Apply"]');
return {open: dialog.open, staged: staged ? [text(staged), staged.getAttribute("aria-label"), staged.dataset.level] : null, focused: Boolean(staged) && document.activeElement === staged, apply: apply ? apply.title : null};
})()"""
def probe(template: str) -> str:
return template.replace("@HELPERS@", base.HELPERS).replace("@UNLABELLED@", base.UNLABELLED)
return template.replace("@HELPERS@", base.HELPERS).replace("@UNLABELLED@", base.UNLABELLED).replace("@CHIPS@", CHIP_STATE)
@unittest.skipUnless(shutil.which(os.environ.get("CHROMIUM", "chromium")), "no Chromium")
@@ -196,13 +249,31 @@ class TestWorkbenchArtifacts(HubCase):
{"width": width, "height": height, "url": f"{self.base}?{width}-clean#artifacts/tree", "wait": 1200, "probe": probe(CLEAN_ALL), "shot": f"{shot}-clean-all.png"},
{"width": width, "height": height, "url": f"{self.base}?{width}#agents/tree", "wait": 1200, "probe": probe(AGENTS), "shot": f"{shot}-agents-ancestry.png"},
{"width": width, "height": height, "url": f"{self.base}?{width}-popups#artifacts/orbit", "wait": 1200, "probe": probe(POPUP_GATES).replace("@REPO@", json.dumps(self.repo)).replace("@THREE@", "true" if width == 1366 else "false"), "shot": f"{shot}-popup-gates.png"},
{"width": width, "height": height, "url": f"{self.base}?{width}-explain#artifacts/orbit", "wait": 1200, "probe": probe(POPUP_EXPLAIN).replace("@REPO@", json.dumps(self.repo)), "shot": f"{shot}-popup-explain.png"},
]
if browser == "chromium":
steps.append({"width": width, "height": height, "url": None, "wait": 0, "keys": ["Enter"], "probe": probe(KEYBOARD), "shot": f"{shot}-popup-keyboard.png"})
return steps
def check_chips(self, explained: dict, typed: dict | None, browser: str, width: int) -> None:
with self.subTest(browser=browser, width=width, part="popup chips and Explain"):
self.assertNotIn("error", explained, explained)
self.assertEqual(explained["chips"], [[words, words, words, 0] for words in DONE_CHIPS])
self.assertEqual(explained["inside"], [True] * 5, "a gate chip or the Explain list overflows the popup")
self.assertEqual((explained["scrolls"], explained["wide"]), (False, False))
self.assertEqual(explained["summary"], ["Explain", True])
self.assertEqual((explained["headings"], explained["terms"]), (EXPLAINED, 25))
self.assertTrue(explained["focused"])
if typed is not None:
with self.subTest(browser=browser, width=width, part="keyboard cycles a chip"):
self.assertEqual(typed["staged"], ["commit: none (staged)", "commit: none (staged)", "none"], typed)
self.assertEqual((typed["open"], typed["focused"], typed["apply"]), (True, True, "Apply 1 gate changes with one passkey signature"), typed)
def check(self, data: dict, browser: str, signs: bool) -> None:
results = iter(data["results"])
for width, _ in base.WIDTHS:
ancestry, staged, clean, agents, popups = next(results), next(results), next(results), next(results), next(results)
ancestry, staged, clean, agents, popups, explained = next(results), next(results), next(results), next(results), next(results), next(results)
self.check_chips(explained, next(results) if browser == "chromium" else None, browser, width)
with self.subTest(browser=browser, width=width, part="popup gate marks"):
self.assertNotIn("error", popups, popups)
views = ["orbit", "chord", "swimlane", *(["3d"] if width == 1366 else [])]
@@ -210,9 +281,7 @@ class TestWorkbenchArtifacts(HubCase):
for found in popups["shown"]:
self.assertNotIn("error", found, found)
self.assertEqual((found["title"], found["group"], found["unlabelled"]), ("feature/done", "Gates of feature/done", []), found)
self.assertEqual([mark[:3] for mark in found["marks"]], [["commit", "test", True], ["merge", "none", True], ["push", "none", True], ["pr", "e2e", False]], found)
self.assertEqual(found["marks"][0][3], "commit: test · from main", found)
self.assertEqual([mark[4] for mark in found["marks"]], [True, True, True, False], found)
self.assertEqual(found["marks"], DONE_MARKS, found)
self.assertEqual(found["marks"], ancestry["done"], "a popup shows other gate levels than the Tree row")
self.assertFalse(popups["wide"])
with self.subTest(browser=browser, width=width, part="unlabelled controls"):
@@ -225,10 +294,9 @@ class TestWorkbenchArtifacts(HubCase):
self.assertEqual(nodes, {"main": 0, "feature": 1, "feature/kept": 1, "feature/done": 2})
self.assertEqual(sorted(ancestry["edges"]), [
["feature", "feature/done", "derived", True], ["feature/kept", "feature/done", "operator", False], ["main", "feature", "recorded", False], ["main", "feature/kept", "derived", True]])
self.assertEqual([mark[:3] for mark in ancestry["done"]], [["commit", "test", True], ["merge", "none", True], ["push", "none", True], ["pr", "e2e", False]])
self.assertEqual([mark[3] for mark in ancestry["done"]][:1], ["commit: test · from main"])
self.assertEqual([mark[4] for mark in ancestry["done"]], [True, True, True, False])
self.assertEqual(ancestry["main"][0][:3], ["commit", "test", False])
self.assertEqual(ancestry["done"], DONE_MARKS)
self.assertEqual(ancestry["main"][0], ["commit", "test", False, "commit: test (own rule)", False, True])
self.assertTrue(ancestry["inside"], "a gate chip of the Tree overflows the viewport")
self.assertEqual((staged["pending"], staged["staged"], staged["count"]), (True, True, "2"), staged)
self.assertEqual(staged["apply"], ["Apply 2 gate changes with one passkey signature", "Apply"])
self.assertEqual(staged["left"], 0 if signs else 2, staged)
+4 -3
View File
@@ -96,7 +96,8 @@ class TestGateMarks(unittest.TestCase):
marks = {mark["action"]: mark for mark in self.data["marks"]}
self.assertEqual(list(marks), ["commit", "merge", "push", "pr"])
self.assertEqual([(marks[a]["level"], marks[a]["own"], marks[a]["inherited"]) for a in marks], [("test", True, False), ("quality-high", False, True), ("none", False, True), ("e2e", True, False)])
self.assertEqual([marks[a]["title"] for a in marks], ["commit: test · own rule", "merge: quality-high · from main", "push: none · no rule", "pr: e2e · own rule"])
self.assertEqual([marks[a]["source"] for a in marks], ["feature/a", "main", "", "feature/a"])
self.assertNotIn("title", marks["commit"])
self.assertEqual([marks[a]["icon"] for a in marks], ["bi-check2-circle", "bi-shield-check", "bi-circle", "bi-browser-chrome"])
def test_a_branch_gates_py_does_not_know_shows_none_inherited_for_every_action(self):
@@ -120,14 +121,14 @@ class TestAncestryAssets(unittest.TestCase):
done = subprocess.run(["node", "--check", str(ANCESTRY)], capture_output=True, text=True, timeout=60, check=False)
self.assertEqual(done.returncode, 0, done.stderr)
self.assertIn("svg .ancestry-edge.derived { stroke-dasharray: 5 5; }", STYLE.read_text(encoding="utf-8"))
self.assertIn(".gate-mark.inherited { opacity: .4; }", STYLE.read_text(encoding="utf-8"))
self.assertIn(".gate-mark.inherited { border-style: dashed; background: transparent; color: var(--muted); }", STYLE.read_text(encoding="utf-8"))
def test_every_new_control_is_an_icon_with_title_and_aria_label(self):
page = PAGE.read_text(encoding="utf-8")
for control in re.findall(r'iconBtn\("(bi-[a-z0-9-]+)", "([^"]+)"', page):
with self.subTest(control=control):
self.assertTrue(control[1])
self.assertIn('...named(`${mark.action} gate`, title)', page)
self.assertIn("...named(revealed(chip.text), revealedLines(chip.hint))", page)
self.assertIn('role: "button", "aria-label": node.label', page)
+187
View File
@@ -0,0 +1,187 @@
from __future__ import annotations
import json
import re
import subprocess
import unittest
from hub_case import HubCase
from hub_support import HUB, signing
TEMPLATES = HUB / "templates"
GLOSSARY = TEMPLATES / "glossary.js"
ANCESTRY = TEMPLATES / "ancestry.js"
MODULES = ["page-constants.js", "glossary.js", "ancestry.js", "page-reveal.js", "page-dom.js", "page-ancestry.js"]
RESOLVED = {"commit": {"level": "test", "source": "feature/a"}, "merge": {"level": "quality-high", "source": "main"}, "push": {"level": "none", "source": None}, "pr": {"level": "e2e", "source": "feature/a"}}
CHIPS = ["commit: test (own rule)", "merge: quality-high (inherited from main)", "push: none (no rule)", "pr: e2e (own rule)"]
# Param: argv[1] is glossary.js, argv[2] ancestry.js, argv[3] the resolved gates; prints the glossary tables, chip texts and Explain sections.
PROBE = """
const G = require(process.argv[1]);
const A = require(process.argv[2]);
const marks = A.gateMarks("feature/a", {resolved: JSON.parse(process.argv[3])});
console.log(JSON.stringify({
actions: A.ACTIONS, levels: A.LEVELS, gateActions: G.GATE_ACTIONS, gateLevels: G.GATE_LEVELS, sources: G.GATE_SOURCES, cycle: G.GATE_CYCLE, receipt: G.RECEIPT,
ruleHints: G.RULE_HINTS, officeVerbs: G.OFFICE_VERBS, branchMarks: G.BRANCH_MARKS,
chips: marks.map((mark) => G.gateChip(mark, null)),
staged: [G.gateChip(marks[2], {level: "quality-high"}), G.gateChip(marks[0], {level: null})],
explain: G.explain(),
}));
"""
# Param: argv[1] is the templates folder, argv[2] the module list and tree as JSON; prints the gate chips and the Explain block the page builds.
RENDER = r"""
const fs = require("fs");
const [dir, given] = [process.argv[1], JSON.parse(process.argv[2])];
const source = given.files.map((name) => fs.readFileSync(`${dir}/${name}`, "utf8")).join("\n");
class FakeNode {
constructor(tag) { this.tag = tag; this.attrs = {}; this.children = []; this.on = []; }
setAttribute(key, value) { this.attrs[key] = value; }
append(...children) { this.children.push(...children); }
addEventListener(name) { this.on.push(name); }
}
const stub = new Proxy(function () {}, {get: (target, key) => (key === Symbol.toPrimitive ? () => "" : key === Symbol.iterator ? [][Symbol.iterator].bind([]) : stub), apply: () => stub});
const sheet = new FakeNode("div");
const provided = {document: {createElement: (tag) => new FakeNode(tag), createElementNS: (ns, tag) => new FakeNode(tag), getElementById: (id) => (id === "emoji-bases" ? {textContent: "[]"} : sheet), addEventListener() {}}, Node: FakeNode, tree: given.tree};
const scope = new Proxy({}, {has: (target, key) => typeof key === "string" && (key in provided || !(key in globalThis)), get: (target, key) => (key === Symbol.unscopables ? undefined : key in provided ? provided[key] : stub)});
const page = new Function("scope", `with (scope) {\n${source}\nreturn {gateChips, gateExplain};\n}`)(scope);
const dump = (node) => (node instanceof FakeNode ? {tag: node.tag, attrs: node.attrs, on: node.on, children: node.children.map(dump)} : String(node));
console.log(JSON.stringify({chips: dump(page.gateChips("/r", "feature/a")), explain: dump(page.gateExplain())}));
"""
def text_of(node: dict | str) -> str:
return node if isinstance(node, str) else "".join(text_of(child) for child in node["children"])
def find(node: dict | str, tag: str) -> list[dict]:
if isinstance(node, str):
return []
return ([node] if node["tag"] == tag else []) + [hit for child in node["children"] for hit in find(child, tag)]
class TestGlossaryTables(unittest.TestCase):
@classmethod
def setUpClass(cls):
done = subprocess.run(["node", "-e", PROBE, str(GLOSSARY), str(ANCESTRY), json.dumps(RESOLVED)], capture_output=True, text=True, timeout=60, check=True)
cls.data = json.loads(done.stdout)
def assertTexts(self, values: list[str]) -> None:
for value in values:
with self.subTest(value=value):
self.assertIsInstance(value, str)
self.assertGreater(len(value.strip()), 3)
self.assertNotIn(chr(0x2014), value)
def test_every_gate_action_and_level_of_gates_py_has_a_meaning(self):
self.assertEqual(list(self.data["gateActions"]), list(signing.GATE_ACTIONS))
self.assertEqual(list(self.data["gateLevels"]), list(signing.GATE_LEVELS))
self.assertEqual((self.data["actions"], self.data["levels"]), (list(signing.GATE_ACTIONS), list(signing.GATE_LEVELS)))
self.assertTexts([*self.data["gateActions"].values(), *self.data["gateLevels"].values()])
def test_every_rule_hint_and_office_verb_keeps_its_key_and_has_a_text(self):
kinds = re.search(r"const RULE_KINDS = \{([^}]*)\}", (TEMPLATES / "page-rules.js").read_text(encoding="utf-8")).group(1)
self.assertEqual(sorted(self.data["ruleHints"]), sorted(re.findall(r"(\w+): \"", kinds)))
self.assertEqual(sorted(self.data["ruleHints"]), ["ask", "decision", "review"])
self.assertEqual(sorted(self.data["officeVerbs"]), ["appoint", "recall", "takeover"])
self.assertTexts(list(self.data["ruleHints"].values()))
for action, (verb, glyph, words) in self.data["officeVerbs"].items():
with self.subTest(action=action):
self.assertRegex(glyph, r"^bi-[a-z0-9-]+$")
self.assertTexts([verb, words])
def test_every_source_branch_mark_receipt_and_the_click_have_a_term_and_a_meaning(self):
self.assertEqual(sorted(self.data["sources"]), ["inherited", "own", "staged", "unset"])
pairs = [*self.data["sources"].values(), *self.data["branchMarks"].values(), self.data["receipt"], self.data["cycle"]]
for pair in pairs:
with self.subTest(pair=pair):
self.assertEqual(len(pair), 2)
self.assertTexts(pair)
def test_a_chip_names_action_level_and_where_the_level_comes_from(self):
self.assertEqual([chip["text"] for chip in self.data["chips"]], CHIPS)
self.assertEqual([chip["text"] for chip in self.data["staged"]], ["push: quality-high (staged)", "commit: inherited (staged)"])
def test_the_chip_tooltip_starts_with_the_chip_text_and_explains_action_level_source_and_click(self):
tables = self.data
merge = tables["chips"][1]["hint"].split("\n")
self.assertEqual(merge, [
CHIPS[1],
f"merge: {tables['gateActions']['merge']}",
f"quality-high: {tables['gateLevels']['quality-high']}",
f"inherited from main: {tables['sources']['inherited'][1]}",
f"{tables['cycle'][0]}: {tables['cycle'][1]}",
])
dropped = tables["staged"][1]["hint"].split("\n")
self.assertEqual(dropped[2:4], [f"inherited: {tables['sources']['inherited'][1]}", f"staged: {tables['sources']['staged'][1]}"])
def test_explain_lists_every_term_of_the_glossary_once(self):
sections = dict(self.data["explain"])
self.assertEqual(list(sections), ["Gate actions", "Gate levels", "Where a level comes from", "Branch marks"])
terms = [term for rows in sections.values() for term, _ in rows]
self.assertEqual(len(terms), len(set(terms)))
expected = [*signing.GATE_ACTIONS, *signing.GATE_LEVELS, self.data["receipt"][0], *(pair[0] for pair in self.data["sources"].values()), self.data["cycle"][0], *(pair[0] for pair in self.data["branchMarks"].values())]
self.assertEqual(terms, expected)
class TestGlossarySource(unittest.TestCase):
def test_rule_hints_and_office_verbs_are_written_only_in_the_glossary_and_re_exported_under_their_old_names(self):
rules = (TEMPLATES / "page-rules.js").read_text(encoding="utf-8")
offices = (TEMPLATES / "page-offices.js").read_text(encoding="utf-8")
self.assertIn(" const RULE_HINTS = Glossary.RULE_HINTS;\n", rules)
self.assertIn(" const OFFICE_VERBS = Glossary.OFFICE_VERBS;\n", offices)
sources = {path.name: path.read_text(encoding="utf-8") for path in TEMPLATES.glob("*.js")}
for words in ("Grants matching asks in matching directories", "Takes the recommended option", "council.py claim --operator on the host", "council.py release --operator on the host"):
with self.subTest(words=words):
self.assertEqual([name for name, text in sources.items() if words in text], ["glossary.js"])
def test_the_glossary_module_parses_on_its_own(self):
done = subprocess.run(["node", "--check", str(GLOSSARY)], capture_output=True, text=True, timeout=60, check=False)
self.assertEqual(done.returncode, 0, done.stderr)
class TestGateChipsRender(unittest.TestCase):
@classmethod
def setUpClass(cls):
tree = {"data": {"gates": {"/r": {"feature/a": {"resolved": RESOLVED, "rules": {"commit": "test", "pr": "e2e"}, "parents": []}}}}}
done = subprocess.run(["node", "-e", RENDER, str(TEMPLATES), json.dumps({"files": MODULES, "tree": tree})], capture_output=True, text=True, timeout=60, check=False)
if done.returncode != 0:
raise AssertionError(done.stderr.strip()[:800])
cls.data = json.loads(done.stdout)
def test_each_gate_is_a_focusable_text_chip_whose_aria_label_is_its_visible_text(self):
group = self.data["chips"]
self.assertEqual((group["tag"], group["attrs"]["role"], group["attrs"]["aria-label"]), ("span", "group", "Gates of feature/a"))
buttons = [child for child in group["children"] if isinstance(child, dict)]
self.assertEqual([button["tag"] for button in buttons], ["button"] * 4)
for button, words in zip(buttons, CHIPS, strict=True):
with self.subTest(chip=words):
self.assertEqual(button["attrs"]["type"], "button")
self.assertNotIn("tabindex", button["attrs"])
self.assertNotIn("icon-only", button["attrs"]["class"].split())
self.assertEqual(button["on"], ["click"])
self.assertEqual(text_of(button), words)
self.assertEqual(button["attrs"]["aria-label"], words)
self.assertTrue(button["attrs"]["title"].startswith(f"{words}\n"))
self.assertEqual([("inherited" in button["attrs"]["class"].split()) for button in buttons], [False, True, True, False])
def test_the_explain_action_is_a_disclosure_listing_every_glossary_term(self):
block = self.data["explain"]
self.assertEqual((block["tag"], block["attrs"]["class"]), ("details", "gate-explain"))
summary = block["children"][0]
self.assertEqual((summary["tag"], text_of(summary)), ("summary", "Explain"))
self.assertEqual([text_of(head) for head in find(block, "h4")], ["Gate actions", "Gate levels", "Where a level comes from", "Branch marks"])
terms = [text_of(term) for term in find(block, "dt")]
self.assertLessEqual({*signing.GATE_ACTIONS, *signing.GATE_LEVELS, "own rule", "inherited from", "no rule", "staged", "merged", "not merged", "Reason"}, set(terms))
self.assertEqual(len(find(block, "dd")), len(terms))
class TestHubGlossary(HubCase):
def test_the_page_ships_the_glossary_before_the_page_scripts_and_the_explain_icon(self):
html = self.index()
module = GLOSSARY.read_text(encoding="utf-8").strip()
self.assertIn(module, html)
self.assertLess(html.index(module), html.index("const RULE_HINTS = Glossary.RULE_HINTS;"))
self.assertIn('<symbol id="bi-question-circle"', html)
if __name__ == "__main__":
unittest.main()
+1 -1
View File
@@ -537,7 +537,7 @@ TREE_PROBE = DOM_KIT + """
const [, artifactsFile, treeFile, homeFile, dataFile] = process.argv.slice(1);
Object.assign(context, {
h, icon: () => text(""), named: (label, hint) => ({title: hint || label, "aria-label": label}), iconBtn: (name, label, cls, run, hint) => h("button", {"aria-label": label, title: hint}),
counter: (value) => text(value), emptyState: (title, words) => h("div", {class: "empty", "data-title": title}, words), branchAncestry: () => null, gateIcons: () => h("span", {class: "gates"}),
counter: (value) => text(value), emptyState: (title, words) => h("div", {class: "empty", "data-title": title}, words), branchAncestry: () => null, gateChips: () => h("span", {class: "gates"}), gateExplain: () => null,
flowLine: () => null, flowDetails: () => null, flowEdges: () => [], copyButton: () => null, face: () => null, person: (name) => text(name), status: (value) => text(value), pill: (words) => text(words),
workChips: () => null, popupHead: (glyph, label) => h("h2", {class: "panel-title"}, label), meta: (rows) => h("dl", {}, rows.map(([key, value]) => h("div", {"data-key": key}, value === null || value === undefined ? "" : value))),
WORK_CHIPS: {}, clock: {format: () => "c"}, stampOf: (t) => t, nowSeconds: () => 1763000000, labelOf: (key) => key, toast: () => null,
+5 -2
View File
@@ -10,7 +10,7 @@ from pathlib import Path
from hub_support import signing
TEMPLATES = Path(__file__).resolve().parent.parent / "orchestrator" / "templates"
MODULES = ["page-constants.js", "ancestry.js", "page-reveal.js", "page-dom.js", "page-diff.js", "page-rule-request.js", "page-inbox.js", "page-firewall.js", "page-review.js", "page-cleanup.js", "page-offices.js", "page-ancestry.js", "page-tasks-prio.js"]
MODULES = ["page-constants.js", "glossary.js", "ancestry.js", "page-reveal.js", "page-dom.js", "page-diff.js", "page-rule-request.js", "page-inbox.js", "page-firewall.js", "page-review.js", "page-cleanup.js", "page-offices.js", "page-ancestry.js", "page-tasks-prio.js"]
RLO, ZWSP, LRI, SEPARATOR, CARRIAGE = chr(0x202E), chr(0x200B), chr(0x2066), chr(0x2028), chr(0x0D)
FILLER, NBSP, CGJ, VS15, VS16 = chr(0x3164), chr(0xA0), chr(0x34F), chr(0xFE0E), chr(0xFE0F)
HIDDEN = (RLO, ZWSP, LRI, SEPARATOR, CARRIAGE, FILLER, NBSP, CGJ, VS16)
@@ -140,7 +140,7 @@ class TestPageReveal(unittest.TestCase):
page_state = {
"state": {"reviews": [review], "inbox": [], "jobs": [{"kind": "task", "task": "T1", "command": f"rasci.py set T1{RLO} --prio 3", "status": "done"}], "graph": {"nodes": []}, "claims": []},
"ui": {"review": None, "file": 0},
"tree": {"data": {"repos": [repo], "gates": {"/r": {"feature/a": {"parents": [{"parent": f"main{FILLER}", "source": "own"}], "rules": {}}}}}},
"tree": {"data": {"repos": [repo], "gates": {"/r": {"feature/a": {"parents": [{"parent": f"main{FILLER}", "source": "own"}], "rules": {}, "resolved": {"merge": {"level": "test", "source": f"main{FILLER}"}}}}}}},
}
calls = [
["reviewSheet", ["r1"]],
@@ -149,12 +149,15 @@ class TestPageReveal(unittest.TestCase):
["branchAncestry", [repo]],
["priorityForm", [{"task": f"T1{FILLER}", "estimates": {}, "prio": 3}]],
["taskJobs", [{"task": "T1"}]],
["gateChips", ["/r", "feature/a"]],
]
found = shown(TEMPLATES, calls, page_state)
self.assertRevealed(found[0], ["202E", "3164", "00A0", "034F", "FE0F"])
for drawn in found[1:5]:
self.assertRevealed(drawn, ["3164"])
self.assertRevealed(found[5], ["202E"])
self.assertRevealed(found[6], ["3164"])
self.assertIn("merge: test (inherited from main⟨U+3164⟩)", found[6])
def test_an_inbox_ask_operator_row_and_decision_show_every_hidden_character_as_a_marker(self):
ask = item("ask", command=f"git status{RLO} && rm -rf ~", directory=f"/repo{ZWSP}", agent=f"Skills{RLO}")