fix: wire destructive_command_guard plugin into hook engine (#316)#320
Merged
mpfaffenberger merged 1 commit intompfaffenberger:mainfrom May 6, 2026
Merged
fix: wire destructive_command_guard plugin into hook engine (#316)#320mpfaffenberger merged 1 commit intompfaffenberger:mainfrom
mpfaffenberger merged 1 commit intompfaffenberger:mainfrom
Conversation
…fault - Register a run_shell_command callback that inspects every shell invocation for destructive patterns - Prompt interactive users for explicit approval before allowing risky commands to proceed - Hard-block destructive commands in non-interactive contexts to prevent accidental data loss in CI and automation - Return structured block responses with clear reasoning and user-facing error messages for safer handling
mpfaffenberger
approved these changes
May 6, 2026
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.
Problem
The
destructive_command_guardplugin (#316) is silently dead code. The plugin loader atcode_puppy/plugins/__init__.py:29requires every built-in plugin to have aregister_callbacks.py. This plugin didn't have one — it shipped onlydetector.py+__init__.py+ a passing test suite. The detection patterns were defined, tested, and never wired.Compare to
force_push_guard/(#310): that plugin hasdetector.pyplusregister_callbacks.pythat callsregister_callback("run_shell_command", ...). That's why #310 actually works and #316 doesn't.Fix
Added
register_callbacks.pytodestructive_command_guard/, following the exact same pattern asforce_push_guard:run_shell_commandphaseget_user_approval_asyncwith a Rich panel (pattern name, description, full command){"blocked": True}and a descriptive error messageVerification
run_shell_commandhook chaingit status) →None(allowed)rm -rf /) → blocked with reasoningFixes #316