Found by the /code-review pass on #329, scored 60 — real, but not a reason to block that PR, since some loosening was genuinely required.
What changed
tests/test_case_divergence_298.py::test_the_per_tool_call_path_is_not_touched used to assert post-tool-hook.sh was byte-identical to origin/main. #299's body cited exactly that as the evidence for its zero-cost claim about the per-tool-call path.
#329 replaced it with three substring checks:
assert "lib-case-divergence" not in code
assert "case_divergence" not in code
assert "git " not in code
Why it had to change
The byte check blocked every edit to post-tool-hook.sh, including #329's own one-character octal fix. It was over-strict by construction: it could not distinguish "someone added cost to the hot path" from "someone fixed a bug in it". Keeping it was not an option.
Why the replacement is too weak
It pattern-matches three literals, so the invariant is now "the file does not mention these three strings" rather than "the hot path costs nothing". Things that reintroduce the #298/#299 defect and stay green:
GIT=git; "$GIT" -C ... — or any wrapper function, or command git
- a divergence check inlined without the literal
case_divergence
- an extra subprocess spawn of anything that is not
git
- an extra file read, or a loop, on the per-tool-call path
The last two are not even in the substring set's vocabulary. #299 exists because cost on this path is paid on every tool call, and the failure is silent — it shows up as latency, not as a red test.
What would actually pin it
Not a byte compare. The property #299 cares about is cost, so measure cost: count subprocess spawns and file reads on the hot path in a harness, and assert the count, the way test_case_divergence_298.py already stubs the environment. A number that has to be edited deliberately is the pin; a substring set is a reminder.
Prior art in this repo: the fork-throttle tests already drive the hook with real marker files and assert on observable behaviour rather than on source text.
Not urgent
Nothing is broken today — the hot path is currently clean, and #329 verified that. This is about what the next PR to touch this file can do without anyone noticing.
Found by the
/code-reviewpass on #329, scored 60 — real, but not a reason to block that PR, since some loosening was genuinely required.What changed
tests/test_case_divergence_298.py::test_the_per_tool_call_path_is_not_touchedused to assertpost-tool-hook.shwas byte-identical toorigin/main. #299's body cited exactly that as the evidence for its zero-cost claim about the per-tool-call path.#329 replaced it with three substring checks:
Why it had to change
The byte check blocked every edit to
post-tool-hook.sh, including #329's own one-character octal fix. It was over-strict by construction: it could not distinguish "someone added cost to the hot path" from "someone fixed a bug in it". Keeping it was not an option.Why the replacement is too weak
It pattern-matches three literals, so the invariant is now "the file does not mention these three strings" rather than "the hot path costs nothing". Things that reintroduce the #298/#299 defect and stay green:
GIT=git; "$GIT" -C ...— or any wrapper function, orcommand gitcase_divergencegitThe last two are not even in the substring set's vocabulary. #299 exists because cost on this path is paid on every tool call, and the failure is silent — it shows up as latency, not as a red test.
What would actually pin it
Not a byte compare. The property #299 cares about is cost, so measure cost: count subprocess spawns and file reads on the hot path in a harness, and assert the count, the way
test_case_divergence_298.pyalready stubs the environment. A number that has to be edited deliberately is the pin; a substring set is a reminder.Prior art in this repo: the fork-throttle tests already drive the hook with real marker files and assert on observable behaviour rather than on source text.
Not urgent
Nothing is broken today — the hot path is currently clean, and #329 verified that. This is about what the next PR to touch this file can do without anyone noticing.