From 31383bcebe61eb490d8810d51cd00bfe9c62adf8 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Sun, 23 Aug 2026 11:05:42 -0400 Subject: [PATCH] test(hooks): the two tests that read a refused connection as "nothing recorded" now answer through a sink, and the silence case removes the shape it had left behind (#2932) Co-Authored-By: Claude Fable 5 --- tests/test_after_write_hook.py | 5 ++++- tests/test_write_path_trigger.py | 38 +++++++++++++++++--------------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/tests/test_after_write_hook.py b/tests/test_after_write_hook.py index 01dfb11..8ac6501 100644 --- a/tests/test_after_write_hook.py +++ b/tests/test_after_write_hook.py @@ -102,7 +102,10 @@ def test_after_write_is_silent_where_it_has_nothing_to_say(tmp_path): (loose / "a.css").write_text(".x {\n color: red;\n}\n") assert _run(loose, env, session="s-loose") == "" # A change that defines nothing (prose, a call-site edit) → nothing, even - # with the server unreachable (port 9 refuses): no definitions, no arms. + # with the server unreachable (port 9 refuses): no definitions, no call + # owed, so not even the #2932 outage line. (a.css above is removed first: + # it DOES define a shape, and an unanswered call for it would rightly speak.) + (repo / "a.css").unlink() (repo / "README.md").write_text("# notes\n") (repo / "b.py").write_text("def one():\n return one_more()\n") assert _run(repo, env, session="s-quiet") == "" diff --git a/tests/test_write_path_trigger.py b/tests/test_write_path_trigger.py index e938f4d..8b0c7d6 100644 --- a/tests/test_write_path_trigger.py +++ b/tests/test_write_path_trigger.py @@ -1033,24 +1033,26 @@ def test_local_arm_finds_duplicates_in_every_language_family( every Go/Kotlin/Rust project, which is exactly where the operator observed recording never happening. Each case stages an existing copy and writes the same definition to a second file; the hook must prove the duplication and - ask for the record.""" - env = _hook_runtime_env() - repo = tmp_path / "repo" - repo.mkdir() - subprocess.run(["git", "init", "-q"], cwd=repo, check=True, env=env) - (repo / fname).write_text(definition) - subprocess.run(["git", "add", "."], cwd=repo, check=True, env=env) - ext = fname.rsplit(".", 1)[1] - out = subprocess.run( - ["bash", str(HOOK)], - input=json.dumps({ - "session_id": f"s-lang-{ext}", "cwd": str(repo), - "tool_name": "Write", - "tool_input": {"file_path": str(repo / f"copy.{ext}"), - "content": definition}, - }), - capture_output=True, text=True, env=env, - ) + ask for the record (the instance ANSWERS "nothing recorded" — since #2932 + an unanswered call withholds the nudge, so a sink stands in for it).""" + with http_sink(b'{"context":"","note_ids":[],"sync_note_ids":[]}') as (port, _seen): + env = dict(_hook_runtime_env(), SCRIBE_URL=f"http://127.0.0.1:{port}") + repo = tmp_path / "repo" + repo.mkdir() + subprocess.run(["git", "init", "-q"], cwd=repo, check=True, env=env) + (repo / fname).write_text(definition) + subprocess.run(["git", "add", "."], cwd=repo, check=True, env=env) + ext = fname.rsplit(".", 1)[1] + out = subprocess.run( + ["bash", str(HOOK)], + input=json.dumps({ + "session_id": f"s-lang-{ext}", "cwd": str(repo), + "tool_name": "Write", + "tool_input": {"file_path": str(repo / f"copy.{ext}"), + "content": definition}, + }), + capture_output=True, text=True, env=env, + ) assert out.returncode == 0 assert out.stdout.strip(), ( f"hook produced no output for {fname} — the local arm should have "