forked from cardosofelipe/fast-next-template
feat(mcp): Guardrails & Safety Framework #63
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Overview
Implement a comprehensive safety framework that prevents runaway agents, validates actions before execution, enables rollback of mistakes, and controls costs. This is NON-NEGOTIABLE for autonomous agent operation.
Parent Epic
Why This Is Critical
The Risks
The Solution
A multi-layered safety system:
Implementation Sub-Tasks
1. Project Setup & Architecture
backend/src/mcp_core/safety/directory__init__.pywith public API exportsguardian.pywithSafetyGuardianclassconfig.pywith Pydantic settings2. Action Validation Framework
validation/validator.pywithActionValidatorclass3. Cost Control System
costs/controller.pywithCostControllerclass4. Rate Limiting
limits/limiter.pywithRateLimiterclass5. Loop Detection & Prevention
loops/detector.pywithLoopDetectorclass6. Permission System
permissions/manager.pywithPermissionManagerclass7. Rollback System
rollback/manager.pywithRollbackManagerclass8. Human-in-the-Loop (HITL)
hitl/manager.pywithHITLManagerclass9. Content Filtering
content/filter.pywithContentFilterclass10. Sandbox Execution
sandbox/executor.pywithSandboxExecutorclass11. Audit System
audit/logger.pywithAuditLoggerclass12. Emergency Controls
emergency/controls.pywith emergency handlers13. Safety Policies
policies/schema.pywith policy definitions14. MCP Integration
check_permissiontool - Verify action is allowedrequest_approvaltool - Request human approvalreport_issuetool - Report safety concernget_budget_statustool - Check remaining budgetcreate_checkpointtool - Create rollback pointrollback_to_checkpointtool - Undo to checkpoint15. Metrics & Observability
actions_blocked_totalcounter by reasonapprovals_requested_totalcounterrollbacks_performed_totalcountercost_budget_remaininggauge by scoperate_limit_hits_totalcounterloop_detections_totalcounter16. Testing
17. Documentation
Technical Specifications
Safety Flow
Safety Policy Schema
Autonomy Level Mapping
Acceptance Criteria
Labels
phase-2,mcp,backend,safety,criticalMilestone
Phase 2: MCP Integration