feat(runner): add git safety guardrails to prevent destructive operations#1225
Open
ambient-code[bot] wants to merge 1 commit intomainfrom
Open
feat(runner): add git safety guardrails to prevent destructive operations#1225ambient-code[bot] wants to merge 1 commit intomainfrom
ambient-code[bot] wants to merge 1 commit intomainfrom
Conversation
…ions Add comprehensive git guardrails to the runner to prevent AI agents from performing irreversible git operations without user authorization. This addresses incidents where agents deleted remote branches (permanently closing PRs), force-pushed to user forks, and ran destructive local operations without backups. Changes: - New git_guardrails.py module with command validation logic that detects dangerous operations (ref deletion, force push, API ref manipulation, reset --hard, clean -fd, etc.) and token exposure in commands - System prompt now includes explicit Git Safety Guardrails section with hard rules and an escalation protocol when git operations fail - 46 unit tests for the guardrails module + 2 prompt integration tests Closes #1111 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
🔄 Circuit breaker reached (retry_count=3)This PR has been checked 3 times by automated maintenance with no actionable issues found:
The PR is healthy and ready for human review. Handing off to a human reviewer. Labels updated: removed |
Contributor
|
Im going to say hold on this, not sure if this type of guardrails is needed, i feel liek we should move to some sort of file rewind instead |
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
git_guardrails.pymodule with regex-based command validation that detects 11 blocked patterns (ref deletion, force push, API ref manipulation,reset --hard,clean -fd, etc.) and 3 warning patterns (rebase,--force-with-lease,--amend)Addresses every recommendation from #1111:
Test plan
test_git_guardrails.pytests passtest_auto_push.pytests pass (including 2 new guardrail prompt tests)Closes #1111
🤖 Generated with Claude Code