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>
194 lines
10 KiB
Python
194 lines
10 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
import os
|
|
import shutil
|
|
import sys
|
|
import unittest
|
|
from pathlib import Path
|
|
from unittest import mock
|
|
|
|
HERE = Path(__file__).resolve().parent
|
|
sys.path[:0] = [str(HERE.parent), str(HERE)]
|
|
|
|
import hub_e2e_kit as base
|
|
import test_match_review_e2e as matched
|
|
from hub_case import HubCase
|
|
from kvb_orchestrator import batches
|
|
|
|
OUT = Path(os.environ.get("E2E_OUT", "/tmp/hub-040-shots"))
|
|
INIT = """() => {
|
|
window.e2eViolations = [];
|
|
document.addEventListener("securitypolicyviolation", (event) => window.e2eViolations.push(`${event.violatedDirective} ${event.blockedURI}`));
|
|
const real = window.fetch.bind(window);
|
|
window.e2eSubmits = [];
|
|
window.e2eMatch = null;
|
|
window.fetch = (input, options) => {
|
|
const url = String(input && input.url ? input.url : input);
|
|
if (url.startsWith("/api/match") && window.e2eMatch) {
|
|
return Promise.resolve(new Response(JSON.stringify({cards: window.e2eMatch}), {headers: {"Content-Type": "application/json"}}));
|
|
}
|
|
if (url === "/api/inbox/approve" && options && typeof options.body === "string") {
|
|
window.e2eSubmits.push(JSON.parse(options.body).items.map((item) => [item.kind, item.id, item.verb]));
|
|
}
|
|
return real(input, options);
|
|
};
|
|
}"""
|
|
STEPS = """
|
|
const served = async () => (await (await fetch("/api/match", {cache: "no-store"})).json()).cards;
|
|
const key = (name) => document.body.dispatchEvent(new KeyboardEvent("keydown", {key: name, bubbles: true, cancelable: true}));
|
|
const releasing = () => Boolean(card() && card().classList.contains("match-release-card"));
|
|
const decideAll = async () => {
|
|
for (let tries = 0; tries < 10 && card() && !releasing(); tries += 1) {
|
|
const front = card();
|
|
const id = front.dataset.card;
|
|
key(front.dataset.stale === "true" || front.hasAttribute("data-blocked") ? "ArrowUp" : "ArrowRight");
|
|
await until(() => !card() || card().dataset.card !== id, 4000);
|
|
await sleep(200);
|
|
}
|
|
return releasing();
|
|
};
|
|
const swipeRight = async () => {
|
|
const head = card().querySelector(".match-head");
|
|
const box = head.getBoundingClientRect();
|
|
const [x, y] = [box.left + box.width / 2, box.top + 20];
|
|
const dx = card().getBoundingClientRect().width * 0.4;
|
|
const at = (cx) => ({bubbles: true, cancelable: true, pointerId: 12, pointerType: "touch", isPrimary: true, button: 0, clientX: cx, clientY: y});
|
|
head.dispatchEvent(new PointerEvent("pointerdown", at(x)));
|
|
window.dispatchEvent(new PointerEvent("pointermove", at(x + dx / 2)));
|
|
const leaning = card().dataset.leaning || "";
|
|
window.dispatchEvent(new PointerEvent("pointerup", at(x + dx)));
|
|
return leaning;
|
|
};
|
|
"""
|
|
CARD040 = """(async () => {@HELPERS@@CARD@@STEPS@
|
|
await screenShown(8000);
|
|
if (!(await until(card, 8000))) {
|
|
return {error: text(document.getElementById("main")).slice(0, 300)};
|
|
}
|
|
await sleep(300);
|
|
const found = {ready: await decideAll()};
|
|
const front = card();
|
|
found.release = Boolean(front && front.closest(".match-deck") && front.querySelector(".match-release"));
|
|
found.layers = all("#main .match-layer").map((node) => node.dataset.card);
|
|
found.block = Boolean(document.querySelector("#main .match-release-block"));
|
|
found.risk = all("#main .match-accept-risk").map((node) => [node.closest(".match-decision").dataset.card, node.getAttribute("aria-pressed")]);
|
|
found.label = text(document.querySelector("#main .match-release"));
|
|
key("ArrowLeft");
|
|
found.back = await until(() => !releasing() && card() && card().dataset.card, 4000);
|
|
document.querySelector("#main .match-open-overview").click();
|
|
found.again = Boolean(await until(releasing, 4000));
|
|
const cards = await served();
|
|
window.e2eMatch = [...cards, {...cards.find((one) => one.id === "@COMMIT@"), id: "review:e2e-new", ref: "e2e-new", hash: "e2e", title: "e2e: arrived meanwhile"}];
|
|
found.arrived = Boolean(await until(() => document.querySelector('#main .match-layer[data-card="review:e2e-new"]'), 10000));
|
|
found.stays = releasing();
|
|
window.e2eMatch = null;
|
|
found.wide = document.documentElement.scrollWidth > innerWidth + 1;
|
|
return found;
|
|
})()"""
|
|
RELEASE = """(async () => {@HELPERS@@CARD@@STEPS@
|
|
await screenShown(8000);
|
|
if (!(await until(card, 8000))) {
|
|
return {error: text(document.getElementById("main")).slice(0, 300)};
|
|
}
|
|
await sleep(300);
|
|
if (!(await decideAll())) {
|
|
return {error: text(document.getElementById("main")).slice(0, 300)};
|
|
}
|
|
const risk = () => document.querySelector('#main .match-decision[data-card="@RED@"] .match-accept-risk');
|
|
const pressed = [];
|
|
for (let clicks = 0; clicks < @CLICKS@; clicks += 1) {
|
|
risk().click();
|
|
await sleep(200);
|
|
pressed.push(risk().getAttribute("aria-pressed"));
|
|
}
|
|
const label = text(document.querySelector("#main .match-release"));
|
|
window.e2eSubmits.length = 0;
|
|
const leaning = @SWIPE@ ? await swipeRight() : (key("ArrowRight"), "");
|
|
await until(() => window.e2eSubmits.length >= @SUBMITS@, 20000);
|
|
await sleep(1500);
|
|
await until(() => card() && !releasing(), 8000);
|
|
return {pressed, label, leaning, submits: window.e2eSubmits, front: card() ? card().dataset.card : null, peeks: all("#main .match-peek").map((node) => node.dataset.card)};
|
|
})()"""
|
|
|
|
|
|
def probe(template: str, **names: str) -> str:
|
|
fills = {"@HELPERS@": base.HELPERS, "@CARD@": matched.CARD, "@STEPS@": STEPS, **{f"@{key.upper()}@": value for key, value in names.items()}}
|
|
for key, value in fills.items():
|
|
template = template.replace(key, value)
|
|
return template
|
|
|
|
|
|
class ReleaseDeck(HubCase):
|
|
drive = base.OrchestratorE2ECase.drive
|
|
authenticator = base.OrchestratorE2ECase.authenticator
|
|
cards = matched.TestMatchReview.cards
|
|
review = matched.TestMatchReview.review
|
|
payload = matched.TestMatchReview.payload
|
|
|
|
def setUp(self):
|
|
super().setUp()
|
|
OUT.mkdir(parents=True, exist_ok=True)
|
|
self.cards()
|
|
diff = [{"path": "src/red.py", "status": "M", "mode": "100644", "additions": 1, "deletions": 0, "patch": "@@ -1,1 +1,2 @@\n line 1\n+red line", "note": ""}]
|
|
arguments = {**self.arguments("feat: red gate", "", self.page("feature-red.html", "<!doctype html><title>p</title>")), "worktree": "/repo/.worktrees/feature/red", "branch": "feature/red", "agent": "Stage", "diff": diff, "gate": "fail"}
|
|
result = self.tool("review_request", arguments)
|
|
self.assertFalse(result["isError"], result)
|
|
self.red = result["structuredContent"]["id"]
|
|
self.base = f"http://localhost:{self.port}/"
|
|
|
|
|
|
@unittest.skipUnless(shutil.which(os.environ.get("CHROMIUM", "chromium")), "no Chromium")
|
|
class TestMatchReleaseCard(ReleaseDeck):
|
|
def release(self, name: str, clicks: int, swipe: bool, submits: int) -> dict:
|
|
step = {"width": 1920, "height": 1080, "url": f"{self.base}?{name}#tasks/match", "wait": 1500, "shot": str(OUT / f"chromium-{name}.png"),
|
|
"probe": probe(RELEASE, red=f"review:{self.red}", clicks=str(clicks), swipe="true" if swipe else "false", submits=str(submits))}
|
|
with mock.patch.object(batches, "UNDO", 0.3):
|
|
data = self.drive([step], self.authenticator(), init=INIT)
|
|
(OUT / f"chromium-{name}.json").write_text(json.dumps(data, indent=1), encoding="utf-8")
|
|
self.assertEqual([error for error in data["errors"] if "/favicon.ico" not in error], [])
|
|
found = data["results"][0]
|
|
self.assertNotIn("error", found, found)
|
|
return found
|
|
|
|
def sorted_submits(self, found: dict) -> list[list[list[str]]]:
|
|
return [sorted(batch) for batch in found["submits"]]
|
|
|
|
def test_chromium_puts_the_release_card_in_front_of_greyed_and_new_cards_and_left_returns_to_the_stack(self):
|
|
steps = [{"width": width, "height": height, "url": f"{self.base}?{width}-card#tasks/match", "wait": 1500, "shot": str(OUT / f"chromium-{width}-release-card.png"),
|
|
"probe": probe(CARD040, commit=f"review:{self.commit}")} for width, height in ((390, 844), (1920, 1080))]
|
|
data = self.drive(steps, None, init=INIT)
|
|
(OUT / "chromium-release-card.json").write_text(json.dumps(data, indent=1), encoding="utf-8")
|
|
self.assertEqual([error for error in data["errors"] if "/favicon.ico" not in error], [])
|
|
for (width, _), found in zip(((390, 844), (1920, 1080)), data["results"], strict=True):
|
|
with self.subTest(width=width):
|
|
self.assertNotIn("error", found, found)
|
|
self.assertEqual((found["ready"], found["release"], found["block"], found["wide"]), (True, True, False, False), found)
|
|
self.assertIn(f"review:{self.stale}", found["layers"], found)
|
|
self.assertEqual(found["risk"], [[f"review:{self.red}", "false"]], found)
|
|
self.assertEqual(found["label"], "Release 2 decisions", found)
|
|
self.assertEqual(found["back"], f"review:{self.stale}", found)
|
|
self.assertEqual((found["again"], found["arrived"], found["stays"]), (True, True, True), found)
|
|
|
|
def test_chromium_release_by_arrow_leaves_the_red_gate_commit_in_the_stack_until_its_risk_is_accepted(self):
|
|
found = self.release("no-risk", 0, False, 1)
|
|
self.assertEqual(self.sorted_submits(found), [sorted([["review", self.commit, "approve"], ["operator", "operator/issue", "approve"]])], found)
|
|
self.assertEqual(found["label"], "Release 2 decisions", found)
|
|
self.assertIn(f"review:{self.red}", [found["front"], *found["peeks"]], found)
|
|
|
|
def test_chromium_release_by_swipe_signs_a_risk_accepted_red_gate_commit_on_its_own_first(self):
|
|
found = self.release("risk", 1, True, 2)
|
|
self.assertEqual((found["pressed"], found["leaning"], found["label"]), (["true"], "accept", "Release 3 decisions"), found)
|
|
self.assertEqual(self.sorted_submits(found), [[["review", self.red, "approve"]], sorted([["review", self.commit, "approve"], ["operator", "operator/issue", "approve"]])], found)
|
|
self.settle(lambda: self.status(self.red) == "approved" and self.status(self.commit) == "approved")
|
|
|
|
def test_chromium_a_withdrawn_risk_leaves_the_red_gate_commit_out_again(self):
|
|
found = self.release("withdrawn", 2, False, 1)
|
|
self.assertEqual((found["pressed"], found["label"]), (["true", "false"], "Release 2 decisions"), found)
|
|
self.assertEqual(self.sorted_submits(found), [sorted([["review", self.commit, "approve"], ["operator", "operator/issue", "approve"]])], found)
|
|
self.assertIn(f"review:{self.red}", [found["front"], *found["peeks"]], found)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|