refactor: unified protect lifecycle via registry, consolidate hookutil#137
Merged
refactor: unified protect lifecycle via registry, consolidate hookutil#137
Conversation
ed89a0a to
e9f12e2
Compare
4a4dec5 to
8560ad3
Compare
Register Claude Code hooks as a registry target so all protection mechanisms (HTTP proxy, MCP wrapping, hooks) use the same PatchAll/ RestoreAll lifecycle. Remove HookInstaller interface and InstallHooks config β hooks are now managed alongside other agents. - Add "Claude Code (hooks)" FuncTarget in registry/builtin.go - protect.UninstallAll() β registry.Default.RestoreAll() (single call) - Remove HookInstaller, claudeHookInstaller, InstallHooks from Config - Simplify EnableAgent/DisableAgent (no special hook handling) - Consolidate hookutil: Install/Uninstall/FormatResponse/IsInstalled/ CleanupStaleFile shared by daemon + libcrust - Fix FreeBSD test (skip root), Windows MSYS2 test (pathutil.ToSlash) - Update lifecycle docs in how-it-works.md and protect.go
8560ad3 to
5f0ee26
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
All protection mechanisms now use a single lifecycle path via the agent registry, ensuring complete cleanup on every exit path.
Before
protect.Stop()called hooks and agent restore independentlydaemon.stopCleanup()had to track both separately (hooks were missed β refactor: unified protect lifecycle via registry, consolidate hookutilΒ #137 bug)HookInstallerinterface andInstallHooksconfig flag added complexityAfter
FuncTargetinregistry/builtin.goprotect.UninstallAll()=registry.Default.RestoreAll()β one call covers everythingHookInstallerinterface,InstallHooks,claudeHookInstallerremovedbuiltin.goArchitecture
Called by:
protect.Stop(),daemon.stopCleanup(),CleanupPID()(unix/windows)hookutil consolidation
Shared by CLI and GUI β moved from scattered locations:
pkg/libcrust/hooks.gointernal/hookutilpkg/libcrust/hook.gointernal/hookutilinternal/agentdetect/detect.gointernal/hookutilpkg/libcrust/hooks.gointernal/hookutilPlatform test fixes
TestWriteFileWithLock_ReadOnlyDirwhen rootpathutil.ToSlashinTestAudit_GitConfigBypassTest plan
go test ./...β zero failures