Repository navigation
fix(install): remove only graphify's own hook entries, keep others (#4359) - #4373
nothariharan wants to merge 1 commit into
Conversation
…raphify-Labs#4359) Hook install/uninstall identified graphify's hooks with `"graphify" in str(group)` over the whole group dict. That removed a user's own command sharing graphify's `hooks` array (with the whole group), and any unrelated group whose command path merely contained the word "graphify" (e.g. a script under `graphify-notes/`). Uninstall rewrote the settings file with no backup, and `_strip_graphify_hook` raised AttributeError on a non-dict entry. Match the individual `hooks[]` entries instead. A graphify entry is a command hook whose command invokes graphify's own `hook-guard`/`hook-check` subcommands (current installs) or references `graphify-out/` (the pre-Graphify-Labs#522 inline bash guard). Only those entries are removed; a group is dropped only when nothing is left in it, and non-dict/non-list shapes are passed through. Applies to the Claude, CodeBuddy, Codex and Gemini install and uninstall filters, keeping them in step. Uninstall now goes through `_write_settings_with_backup`, so it keeps a rolling `.graphify-bak` like install already did. Adds tests covering a user command sharing graphify's group, an unrelated group whose path contains "graphify", a non-dict entry, and the legacy-bash replacement plus idempotency for each host.
|
Thanks for the pull request, @nothariharan. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify reviewed this change.
No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.
Not checked: tests were not run; no formal proof of the changed code.
Graphify review — findings
Replaces the whole-group "graphify" in str(group) match in the Claude, CodeBuddy, Codex and Gemini hook install/uninstall paths with _strip_graphify_hooks, which removes only individual command entries graphify wrote. Those are entries naming hook-guard/hook-check, or the legacy graphify-out/ bash guard. User commands sharing a group and unrelated groups whose path merely contains "graphify" now survive, a group is dropped only once it's emptied, and non-dict or malformed entries pass through untouched. Uninstall now skips non-list sections, does nothing when nothing changed, and writes through _write_settings_with_backup instead of overwriting the file without a backup.
No blocking issues surfaced. 1 lower-confidence candidate did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 590 functions depend on the 178 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
_install_claude_hook()— 6 callers, 5 callees - worse:
_install_codex_hook()— 5 callers, 5 callees - worse:
_install_codebuddy_hook()— 3 callers, 5 callees - worse:
_install_gemini_hook()— 3 callers, 5 callees
Verification — 590 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 401 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
40 of 391 test file(s) selected (10%) via static blast radius.
tests/test_affected_cli.py— impacttests/test_agents_platform.py— impacttests/test_atomic_version_stamp.py— impacttests/test_claude_md.py— impacttests/test_codebuddy.py— impacttests/test_dedup_shrink_refuses_force_write.py— impacttests/test_detect.py— impacttests/test_devin.py— impacttests/test_explain_cli.py— impacttests/test_explain_same_file_tie.py— impacttests/test_extract_cli.py— impacttests/test_gemini_hook.py— impacttests/test_global_add_tag_inference.py— impacttests/test_god_nodes_cli.py— impacttests/test_hollow_chunks_arm_shrink_guard.py— impacttests/test_home_sandbox.py— impacttests/test_hook_strict.py— impacttests/test_incomplete_build_guard.py— impacttests/test_install.py— impacttests/test_install_hook_identity.py— impact, changed-testtests/test_install_references.py— impacttests/test_install_strings.py— impacttests/test_install_version_warning.py— impacttests/test_lookup_exit_codes.py— impacttests/test_merge_chunks_validation.py— impacttests/test_multigraph_diagnostics.py— impacttests/test_no_dedup_flag.py— impacttests/test_opencode_plugin_refresh.py— impacttests/test_path_cli.py— impacttests/test_query_cli.py— impacttests/test_query_induced_edges.py— impacttests/test_read_hook.py— impacttests/test_replace_or_append_section.py— impacttests/test_search_hook.py— impacttests/test_skill_auto_refresh.py— impacttests/test_skill_version_warning.py— impacttests/test_truncation_full_answer.py— impacttests/test_uninstall_purge_safety.py— impacttests/test_uninstall_scope.py— impacttests/test_unverified_semantic_shrink.py— impact
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
· 4 more finding(s) on lines outside this diff (see the check run).
|
Shipped in v0.9.88, just released to PyPI as |
What this fixes
Closes #4359.
When graphify installed or removed its
PreToolUse/BeforeToolhooks, it identified its own hooks with"graphify" in str(group)over the whole group dict.str(group)covers{"matcher": ..., "hooks": [...]}, not graphify's individual command, so:hooksarray of one of graphify's groups was removed with the group on the next install/uninstall.graphify(e.g.python /tools/graphify-notes/check.py) was removed too._strip_graphify_hookraisedAttributeErroron a non-dict entry.Confirmed real on
v8(0.9.87)The fix
Hook entries are now matched at the entry level, not the group level:
_is_graphify_hook_command(command)— true when a command invokes graphify's ownhook-guard <search|read|gemini>/hook-checksubcommands, or referencesgraphify-out/(which identifies the pre-codex install writes bash-only PreToolUse hook that fails on Windows PowerShell #522 inline bash guard, so legacy entries are still cleaned up)._is_graphify_hook_entry(entry)— the entry is atype: "command"hook whose command matches the above. Non-dict / non-command entries are never graphify's (and no longer crash uninstall)._strip_graphify_hooks(groups)— removes only graphify's entries from each group, keeps every other entry, and drops a group only once it has nothing left. Non-dict groups and non-listhookspass through untouched; a group with no graphify entry is never rewritten.Applied to all four hook hosts, install and uninstall, so the filters stay in step:
_install_claude_hook_strip_graphify_hook_install_codebuddy_hook_uninstall_codebuddy_hook_install_codex_hook_uninstall_codex_hook_install_gemini_hook_uninstall_gemini_hookThe uninstall paths now write through
_write_settings_with_backup, so they keep the same rolling.graphify-bakthat install already did.Tests
New
tests/test_install_hook_identity.py:graphify, while removing graphify's own commands, and writes a backup._is_graphify_hook_command(recognises graphify's variants + legacy, rejectsgraphify-notes-style paths) and_strip_graphify_hooks(keeps user entries, drops only emptied groups, passes malformed shapes through).Verification:
19 passed; pre-fix the same suite fails16cases.160 passed, 3 skipped(settings-merge + install + new).ruff checkclean.