Files
skills/tests/e2e/test_match_rejects_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

171 lines
7.4 KiB
Python

from __future__ import annotations
import json
import os
import shutil
import sys
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_match_review_e2e as matched
from hub_case import HubCase
OUT = Path(os.environ.get("E2E_OUT", "/tmp/hub-039-shots"))
INIT = """() => {
window.e2eViolations = [];
document.addEventListener("securitypolicyviolation", (event) => window.e2eViolations.push(`${event.violatedDirective} ${event.blockedURI}`));
const real = window.fetch.bind(window);
window.e2eSent = [];
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/messages" && options && options.method === "POST") {
window.e2eSent.push(JSON.parse(options.body));
}
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}));
const actionable = async () => {
for (let tries = 0; tries < 6 && card() && card().querySelector(".match-stale-note, [data-stale='true']"); tries += 1) {
key("ArrowUp");
await sleep(600);
}
return card() && card().dataset.card;
};
const reject = async (words) => {
const id = await actionable();
key("ArrowLeft");
const field = await until(() => document.querySelector(".match-feedback"), 4000);
if (!field) {
return null;
}
field.value = words;
document.querySelector(".match-feedback-reject").click();
await until(() => !card() || card().dataset.card !== id, 4000);
return id;
};
const release = async () => {
const open = document.querySelector("#main .match-open-overview");
if (open && !open.hidden) {
open.click();
}
return until(() => document.querySelector("#main .match-overview"), 8000);
};
const serve = async (cards) => {
window.e2eMatch = cards;
await sleep(2600);
window.dispatchEvent(new Event("focus"));
};
"""
CHANGED = """(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 cards = await served();
const id = await reject("fix the probe");
await serve(cards.map((one) => (one.id === id ? {...one, hash: `${one.hash}0`} : one)));
await release();
const note = await until(() => document.querySelector(`#main .match-decision[data-card="${id}"] .match-decision-note`), 8000);
const row = document.querySelector(`#main .match-decision[data-card="${id}"]`);
return {id, verdict: row && row.dataset.verdict, note: note ? text(note) : null};
})()"""
ACCEPTED = """(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 cards = await served();
const id = await actionable();
const title = (cards.find((one) => one.id === id) || {}).title;
key("ArrowRight");
await until(() => !card() || card().dataset.card !== id, 4000);
const tally = () => text(document.querySelector("#main .match-tally"));
const before = tally();
const shown = new Set(all("#toasts .toast"));
await serve(cards.map((one) => (one.id === id ? {...one, hash: `${one.hash}0`} : one)));
const toast = await until(() => all("#toasts .toast").filter((node) => !shown.has(node)).map(text).find((entry) => entry.startsWith("Accept dropped")), 8000);
return {id, title, before, after: tally(), toast: toast || null};
})()"""
WITHDRAWN = """(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 cards = await served();
const id = await reject("withdrawn probe");
const title = (cards.find((one) => one.id === id) || {}).title;
await serve(cards.filter((one) => one.id !== id));
await release();
const row = await until(() => document.querySelector(`#main .match-decision[data-card="${id}"][data-withdrawn="true"]`), 8000);
const button = document.querySelector("#main .match-release");
if (!row || !button) {
return {id, row: Boolean(row), button: Boolean(button)};
}
button.click();
await until(() => window.e2eSent.length, 15000);
return {id, title, row: true, sent: window.e2eSent.map((message) => ({cls: message.class, text: message.text}))};
})()"""
def probe(template: str) -> str:
return template.replace("@HELPERS@", base.HELPERS).replace("@CARD@", matched.CARD).replace("@STEPS@", STEPS)
@unittest.skipUnless(shutil.which(os.environ.get("CHROMIUM", "chromium")), "no Chromium")
class TestMatchRejects(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()
self.base = f"http://localhost:{self.port}/"
def test_chromium_keeps_a_reject_across_a_changed_or_withdrawn_card_and_drops_a_changed_accept_with_a_toast(self):
at = {"width": 1366, "height": 900}
steps = [
{**at, "url": f"{self.base}?changed#tasks/match", "wait": 1500, "probe": probe(CHANGED), "shot": str(OUT / "chromium-changed.png")},
{**at, "url": f"{self.base}?accepted#tasks/match", "wait": 1500, "probe": probe(ACCEPTED), "shot": str(OUT / "chromium-accepted.png")},
{**at, "url": f"{self.base}?withdrawn#tasks/match", "wait": 1500, "probe": probe(WITHDRAWN), "shot": str(OUT / "chromium-withdrawn.png")},
]
data = self.drive(steps, self.authenticator(), init=INIT)
(OUT / "chromium-match-rejects.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], [])
changed, accepted, withdrawn = data["results"]
with self.subTest(case="changed reject"):
self.assertNotIn("error", changed, changed)
self.assertEqual(changed["verdict"], "reject", changed)
self.assertIn("changed since your reject", changed["note"], changed)
with self.subTest(case="changed accept"):
self.assertNotIn("error", accepted, accepted)
self.assertEqual((accepted["before"], accepted["after"]), ("1", "0"), accepted)
self.assertIn(accepted["title"], accepted["toast"] or "", accepted)
with self.subTest(case="withdrawn reject"):
self.assertNotIn("error", withdrawn, withdrawn)
self.assertTrue(withdrawn["row"], withdrawn)
calls = [message for message in withdrawn["sent"] if message["cls"] == "call"]
self.assertEqual(len(calls), 1, withdrawn)
self.assertIn(withdrawn["title"], calls[0]["text"], withdrawn)
self.assertIn("withdrawn probe", calls[0]["text"], withdrawn)
if __name__ == "__main__":
unittest.main()