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

66 lines
2.9 KiB
Python

from __future__ import annotations
import json
import os
import subprocess
import tempfile
import unittest
from pathlib import Path
from unittest import mock
import hub_support # noqa: F401
import sessions
import settings_writer
import staged_diff
ENV = {"PATH": "/usr/bin:/bin", "HOME": "/nonexistent", "GIT_CONFIG_NOSYSTEM": "1", "GIT_CONFIG_GLOBAL": os.devnull}
class TestHostWrites(unittest.TestCase):
def setUp(self):
tmp = tempfile.TemporaryDirectory()
self.addCleanup(tmp.cleanup)
self.base = Path(tmp.name)
def test_an_unchanged_sessions_snapshot_is_rewritten_only_after_the_refresh(self):
output = self.base / "agent-sessions.json"
data = {"written": 1000.0, "sessions": {"s1": {"name": "One", "running": True}}}
sessions.write(output, data)
first = output.stat().st_ino
sessions.write(output, {**data, "written": 1000.0 + sessions.REFRESH - 1})
self.assertEqual((output.stat().st_ino, json.loads(output.read_text(encoding="utf-8"))["written"]), (first, 1000.0))
sessions.write(output, {**data, "written": 1000.0 + sessions.REFRESH})
self.assertEqual(json.loads(output.read_text(encoding="utf-8"))["written"], 1000.0 + sessions.REFRESH)
changed = {"written": 1000.0 + sessions.REFRESH + 1, "sessions": {}}
sessions.write(output, changed)
self.assertEqual(json.loads(output.read_text(encoding="utf-8")), changed)
def test_a_settings_view_that_differs_only_in_its_stamp_stays(self):
folder = self.base / "firewall"
folder.mkdir(mode=0o700)
path = folder / "view.json"
view = {"written": 1.0, "files": [{"path": "/x", "exists": True}], "known": []}
settings_writer.write_view(path, view)
first = path.stat().st_ino
settings_writer.write_view(path, {**view, "written": 2.0})
self.assertEqual((path.stat().st_ino, json.loads(path.read_text(encoding="utf-8"))["written"]), (first, 1.0))
settings_writer.write_view(path, {**view, "written": 3.0, "known": ["server"]})
self.assertEqual(json.loads(path.read_text(encoding="utf-8"))["known"], ["server"])
def test_a_toplevel_comes_from_git_once_until_head_moves(self):
repo = self.base / "repo"
sub = repo / "a" / "b"
sub.mkdir(parents=True)
subprocess.run(["git", "init", "-q", "-b", "main", str(repo)], env=ENV, check=True)
staged_diff.TOPLEVELS.clear()
with mock.patch.object(staged_diff, "git", wraps=staged_diff.git) as calls:
self.assertEqual((staged_diff.toplevel(sub), staged_diff.toplevel(sub)), (repo.resolve(), repo.resolve()))
self.assertEqual(calls.call_count, 1)
subprocess.run(["git", "symbolic-ref", "HEAD", "refs/heads/other"], cwd=repo, env=ENV, check=True)
self.assertEqual(staged_diff.toplevel(sub), repo.resolve())
self.assertEqual(calls.call_count, 2)
if __name__ == "__main__":
unittest.main()