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>
158 lines
9.1 KiB
Python
158 lines
9.1 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
|
|
from hub_support import ASK
|
|
from kvb_orchestrator import batches
|
|
|
|
OUT = Path(os.environ.get("E2E_OUT", "/tmp/hub-047-shots"))
|
|
LONG = "\n".join(f"echo line {number}" for number in range(1, 201))
|
|
SHIP = "make ship " + " ".join(f"ARG{number}=value" for number in range(40))
|
|
KIT = """
|
|
const press = async (button) => {
|
|
button.click();
|
|
await sleep(250);
|
|
return button.getAttribute("aria-expanded");
|
|
};
|
|
const look = (box) => {
|
|
const body = box.querySelector(".code-body");
|
|
const foot = box.querySelector(".code-foot");
|
|
return {
|
|
last: box.lastElementChild === foot, foot: all("button", foot).map(name), expanded: foot.querySelector(".code-eye").getAttribute("aria-expanded"),
|
|
clipped: body.scrollHeight > body.clientHeight + 1,
|
|
};
|
|
};
|
|
const toggle = async (box) => {
|
|
const eye = box.querySelector(".code-eye");
|
|
const first = {...look(box)};
|
|
const opened = await press(eye);
|
|
const full = {expanded: opened, clipped: look(box).clipped};
|
|
const closed = await press(eye);
|
|
return {first, full, closed: {expanded: closed, clipped: look(box).clipped}};
|
|
};
|
|
const loose = (selector) => all(selector).filter((node) => !node.closest(".code-box")).length;
|
|
"""
|
|
STREAM = """(async () => {@HELPERS@@KIT@
|
|
await streamShowsAll();
|
|
const rowOf = () => document.querySelector('#main .feed > li[data-ref="@ASK@"]');
|
|
const reviewOf = () => all("#main .feed > li.k-review").find((li) => !li.classList.contains("waiting") && text(li).includes("@REVIEW_TITLE@"));
|
|
await until(() => rowOf() && reviewOf(), 8000);
|
|
await sleep(1500);
|
|
const [row, review] = [rowOf(), reviewOf()];
|
|
if (!row || !review) {
|
|
return {error: text(document.getElementById("main")).slice(0, 300)};
|
|
}
|
|
const ask = await toggle(row.querySelector(".code-box"));
|
|
const box = review.querySelector(".code-box");
|
|
const before = box ? box.querySelectorAll(".diff-file").length : null;
|
|
box.querySelector(".code-eye").click();
|
|
const loaded = Boolean(await until(() => all("#main .feed > li.k-review").find((li) => text(li).includes("@REVIEW_TITLE@") && li.querySelector(".code-box .diff-file")), 8000));
|
|
return {ask, before, loaded, sheet: Boolean(document.querySelector("#sheet:not([hidden])")), loose: loose("#main .command, #main .diff-file"), wide: document.documentElement.scrollWidth > innerWidth + 1};
|
|
})()"""
|
|
OPERATOR = """(async () => {@HELPERS@@KIT@
|
|
const row = await until(() => document.querySelector('#main .inbox-list > li[data-ref="@ASK@"]'), 8000);
|
|
if (!row) {
|
|
return {error: text(document.getElementById("main")).slice(0, 300)};
|
|
}
|
|
return {ask: await toggle(row.querySelector(".code-box")), loose: loose("#main .command, #main .diff-file"), wide: document.documentElement.scrollWidth > innerWidth + 1};
|
|
})()"""
|
|
MATCH = """(async () => {@HELPERS@@KIT@
|
|
const front = () => document.querySelector("#main .match-card.front");
|
|
await until(front, 8000);
|
|
for (let tries = 0; tries < 12 && front() && front().dataset.card !== "@ASK@"; tries += 1) {
|
|
const id = front().dataset.card;
|
|
document.body.dispatchEvent(new KeyboardEvent("keydown", {key: "w", bubbles: true, cancelable: true}));
|
|
await until(() => front() && front().dataset.card !== id, 3000);
|
|
await sleep(200);
|
|
}
|
|
const card = front();
|
|
if (!card || card.dataset.card !== "@ASK@") {
|
|
return {error: card ? card.dataset.card : "no card"};
|
|
}
|
|
const box = card.querySelector(".code-box");
|
|
const body = card.querySelector(".match-body");
|
|
return {box: look(box), place: box.dataset.place, scrolls: body.scrollHeight > body.clientHeight + 1, overflowY: getComputedStyle(body).overflowY,
|
|
page: document.documentElement.scrollHeight > innerHeight + 1, loose: loose("#main .match-command, #main .match-file")};
|
|
})()"""
|
|
TASKS = """(async () => {@HELPERS@@KIT@
|
|
const row = await until(() => document.querySelector('#main li[data-task="operator/ship"]'), 8000);
|
|
if (!row) {
|
|
return {error: text(document.getElementById("main")).slice(0, 300)};
|
|
}
|
|
const box = row.querySelector(".code-box");
|
|
const first = look(box);
|
|
box.querySelector(".code-eye").click();
|
|
const sheet = await until(() => document.querySelector('#sheet:not([hidden]) .code-box[data-place="sheet"]'), 4000);
|
|
const full = sheet ? text(sheet) : null;
|
|
document.dispatchEvent(new KeyboardEvent("keydown", {key: "Escape", bubbles: true}));
|
|
const closed = Boolean(await until(() => !document.querySelector("#sheet:not([hidden])"), 4000));
|
|
return {place: box.dataset.place, first, full, closed, loose: loose("#main .command, #main .diff-file")};
|
|
})()"""
|
|
|
|
|
|
@unittest.skipUnless(shutil.which(os.environ.get("CHROMIUM", "chromium")), "no Chromium")
|
|
class TestOneCodeBox(base.OrchestratorE2ECase):
|
|
def setUp(self):
|
|
super().setUp()
|
|
OUT.mkdir(parents=True, exist_ok=True)
|
|
self.ask =f"ask:{self.create_ask({**ASK, 'command': LONG, 'timeout': 3600})}"
|
|
register = json.loads((self.council / "rasci.json").read_text(encoding="utf-8"))
|
|
register["operator/ship"] = {"title": SHIP, "workdir": "/repo", "status": "running", "roles": {"Operator": "R"}}
|
|
self.write_council({"rasci.json": register})
|
|
diff = [{"path": "src/box.py", "status": "M", "mode": "100644", "additions": 1, "deletions": 0, "patch": "@@ -1,1 +1,2 @@\n line 1\n+box line", "note": ""}]
|
|
self.review_title = "feat: decided box"
|
|
arguments = {**self.arguments(self.review_title, "", self.page("box.html", "<!doctype html><title>p</title>")), "worktree": "/repo/.worktrees/feature/box", "branch": "feature/box", "agent": "Stage", "diff": diff}
|
|
review = self.tool("review_request", arguments)["structuredContent"]["id"]
|
|
entries = [self.entry("review", review, "", "")]
|
|
with mock.patch.object(batches, "UNDO", 0.05):
|
|
self.assertEqual(self.approve(entries, self.signed(entries, self.pin()))[0], 202)
|
|
self.settle(lambda: self.status(review) == "approved")
|
|
|
|
def fill(self, probe: str) -> str:
|
|
return probe.replace("@HELPERS@", base.HELPERS).replace("@KIT@", KIT).replace("@ASK@", self.ask).replace("@REVIEW_TITLE@", self.review_title)
|
|
|
|
def test_chromium_puts_every_command_and_diff_in_one_code_box_whose_eye_toggles_in_place_at_1920_and_390(self):
|
|
steps = []
|
|
for width, height in ((1920, 1080), (390, 844)):
|
|
page = f"{self.base}?{width}"
|
|
steps += [
|
|
{"width": width, "height": height, "url": f"{page}-stream#stream", "wait": 1500, "probe": self.fill(STREAM), "shot": str(OUT / f"chromium-{width}-stream.png")},
|
|
{"width": width, "height": height, "url": f"{page}-operator#tasks/operator", "wait": 1500, "probe": self.fill(OPERATOR), "shot": str(OUT / f"chromium-{width}-operator.png")},
|
|
{"width": width, "height": height, "url": f"{page}-match#tasks/match", "wait": 1500, "probe": self.fill(MATCH), "shot": str(OUT / f"chromium-{width}-match.png")},
|
|
{"width": width, "height": height, "url": f"{page}-tasks#tasks/list", "wait": 1500, "probe": self.fill(TASKS), "shot": str(OUT / f"chromium-{width}-tasks.png")},
|
|
]
|
|
data = self.drive(steps, None)
|
|
(OUT / "chromium-code-box.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 index, width in enumerate((1920, 390)):
|
|
stream, operator, match, tasks = data["results"][index * 4:index * 4 + 4]
|
|
with self.subTest(width=width):
|
|
for found in (stream, operator, match, tasks):
|
|
self.assertNotIn("error", found, found)
|
|
self.assertEqual(found["loose"], 0, found)
|
|
for found in (stream["ask"], operator["ask"]):
|
|
self.assertEqual((found["first"]["last"], found["first"]["expanded"], found["first"]["clipped"]), (True, "false", True), found)
|
|
self.assertEqual(found["first"]["foot"][:2], ["Copy", "Show all"], found)
|
|
self.assertTrue({"Grant", "Deny"} <= set(found["first"]["foot"]), found)
|
|
self.assertEqual(found["full"], {"expanded": "true", "clipped": False}, found)
|
|
self.assertEqual(found["closed"], {"expanded": "false", "clipped": True}, found)
|
|
self.assertEqual((stream["before"], stream["loaded"], stream["sheet"], stream["wide"], operator["wide"]), (0, True, False, False, False), stream)
|
|
self.assertEqual((match["place"], match["box"]["expanded"], match["box"]["last"], match["box"]["foot"]), ("open", "true", True, ["Copy", "Show less"]), match)
|
|
self.assertEqual((match["scrolls"], match["overflowY"], match["page"]), (True, "auto", False), match)
|
|
self.assertEqual((tasks["place"], tasks["first"]["expanded"], tasks["closed"]), ("closed", "false", True), tasks)
|
|
self.assertIn(SHIP, tasks["full"], tasks)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|