graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
fix: do not hang tuiguard probes on a quiet xclip stdin
Rachfe6ad7facb44
diff --git a/docs/adr/0097-isolate-probe-clipboards.md b/docs/adr/0097-isolate-probe-clipboards.mdindex 5b98631b..10df8d27 100644--- a/docs/adr/0097-isolate-probe-clipboards.md+++ b/docs/adr/0097-isolate-probe-clipboards.md@@ -27,6 +27,10 @@ without interfering with concurrent runs or normal desktop use. They do not testthe operating system's clipboard service. Direct invocation of the individualprobe scripts retains that integration path when it is explicitly wanted.+A private `xclip` that treats every non-pbpaste invocation as a write blocks on+stdin. Hover (and any probe that only finds `xclip` on PATH) never finishes a+paint sweep. Read when stdin stays quiet; keep `-i`/`pbcopy` as writes.+The pool integrity suite covers copy/paste, independent environments, cleanup,-and environment inheritance. The real-binary pool covers the complete selection-path with these commands in place.+quiet-stdin reads, and environment inheritance. The real-binary pool covers the+complete selection path with these commands in place.diff --git a/scripts/eval/clipboard_fixture.py b/scripts/eval/clipboard_fixture.pyindex 4aacf0e8..aa92443b 100644--- a/scripts/eval/clipboard_fixture.py+++ b/scripts/eval/clipboard_fixture.py@@ -20,9 +20,12 @@ def private_clipboard():clipboard.write_bytes(b"")handler = root / "clipboard.py"handler.write_text(- "import os, pathlib, sys\n"+ "import os, pathlib, select, sys\n""path = pathlib.Path(__file__).with_name('clipboard')\n"- "if sys.argv[1] in ('pbpaste',) or '-o' in sys.argv[2:] or '-out' in sys.argv[2:]:\n"+ "args = sys.argv[1:]\n"+ "reading = args[:1] == ['pbpaste'] or '-o' in args or '-out' in args\n"+ "writing = '-i' in args or '-in' in args or args[:1] == ['pbcopy']\n"+ "if reading or (not writing and not select.select([sys.stdin], [], [], 0.05)[0]):\n"" sys.stdout.buffer.write(path.read_bytes())\n""else:\n"" temporary = path.with_name('write-' + str(os.getpid()))\n"diff --git a/scripts/eval/test_tier1_tuiguard.py b/scripts/eval/test_tier1_tuiguard.pyindex f501a343..4763ae1b 100644--- a/scripts/eval/test_tier1_tuiguard.py+++ b/scripts/eval/test_tier1_tuiguard.py@@ -128,6 +128,29 @@ class ClipboardTests(unittest.TestCase):self.clipboard(env, copy, data)self.assertEqual(self.clipboard(env, paste), data)+ def test_xclip_quiet_stdin_reads_instead_of_blocking(self) -> None:+ # Hover (and any probe that only finds xclip) invokes it with a quiet+ # stdin. Treat that as a read; blocking on stdin hung the paint sweep.+ with tuiguard.private_clipboard() as env:+ self.clipboard(env, ["pbcopy"], b"seeded")+ read_end, write_end = os.pipe()+ try:+ started = time.monotonic()+ out = subprocess.run(+ ["xclip", "-selection", "clipboard"],+ stdin=read_end,+ stdout=subprocess.PIPE,+ stderr=subprocess.PIPE,+ env=env,+ check=True,+ timeout=2,+ ).stdout+ self.assertLess(time.monotonic() - started, 1.0)+ self.assertEqual(out, b"seeded")+ finally:+ os.close(read_end)+ os.close(write_end)+def test_concurrent_contexts_do_not_interfere(self) -> None:barrier = Barrier(2)