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

68 lines
3.5 KiB
Python

from __future__ import annotations
import json
import time
import unittest
from hub_case import HubCase
from hub_support import key, signing
from kvb_orchestrator import settings
ALL_ON = {source: {"on": True, "until": 0} for source in settings.POPUP_SOURCES}
class TestHubPopups(HubCase):
def notified(self) -> dict | None:
file = self.council / settings.NOTIFY
return json.loads(file.read_text(encoding="utf-8")) if file.exists() else None
def request(self, payload: dict) -> dict | None:
status, _, body = self.post_json("/api/settings/sign", payload, self.guard(self.host))
self.assertEqual(status, 200, body)
return json.loads(body)["payload"]
def test_every_save_writes_notify_json_and_a_popup_change_needs_the_passkey(self):
good = self.guard(self.host)
current = self.snapshot()["settings"]
self.assertEqual(current["popups"], ALL_ON)
quiet = {**current, "channels": {**current["channels"], "sounds": False}}
self.assertIsNone(self.request(quiet))
self.assertEqual(self.post_json("/api/settings", {**quiet, "proof": None}, good)[0], 200)
self.assertEqual(self.notified(), ALL_ON)
muted = {**quiet, "popups": {**ALL_ON, "resources": {"on": False, "until": 0}}}
self.assertEqual(self.post_json("/api/settings", {**muted, "proof": None}, good)[:3:2], (400, b"not signed: no signature\n"))
self.assertEqual(self.notified(), ALL_ON)
signer = self.pin()
request = self.request(muted)
self.assertEqual(request["items"], [signing.item_hash(signing.popups_item(muted["popups"]))])
stranger = self.post_json("/api/settings", {**muted, "proof": key(-7, "stranger").proof(request, self.origin)}, good)
self.assertEqual(stranger[:3:2], (400, b"not signed: the signing key is not pinned\n"))
snoozed = {**quiet, "popups": {**ALL_ON, "mayday": {"on": True, "until": int(time.time()) + 3600}}}
self.assertEqual(self.post_json("/api/settings", {**snoozed, "proof": signer.proof(request, self.origin)}, good)[:3:2], (400, b"not signed: the signature does not list this item\n"))
self.assertEqual(self.notified(), ALL_ON)
status, _, body = self.post_json("/api/settings", {**muted, "proof": signer.proof(request, self.origin)}, good)
self.assertEqual((status, json.loads(body)["settings"]["popups"]), (200, muted["popups"]), body)
self.assertEqual(self.notified(), muted["popups"])
self.assertEqual(settings.Settings(self.state / "settings.json").get()["popups"], muted["popups"])
def test_a_popup_entry_must_name_every_source_with_a_bool_and_a_whole_second(self):
current = self.snapshot()["settings"]
wrongs = [
{**ALL_ON, "dream": {"on": "yes", "until": 0}},
{**ALL_ON, "dream": {"on": True, "until": -1}},
{**ALL_ON, "dream": {"on": True, "until": 2.5}},
{**ALL_ON, "dream": {"on": True, "until": True}},
{**ALL_ON, "dream": {"on": True, "until": settings.POPUP_UNTIL + 1}},
{**ALL_ON, "dream": {"on": True}},
{**ALL_ON, "dream": {"on": True, "until": 0, "extra": 1}},
{source: entry for source, entry in ALL_ON.items() if source != "dream"},
{**ALL_ON, "email": {"on": True, "until": 0}},
]
for wrong in wrongs:
with self.subTest(wrong=wrong):
self.assertEqual(self.post_json("/api/settings/sign", {**current, "popups": wrong}, self.guard(self.host))[0], 400)
if __name__ == "__main__":
unittest.main()