UNPKG

mega-minds

Version:

Enhanced multi-agent workflow system for Claude Code projects with automated handoff management and Claude Code hooks integration

333 lines (257 loc) 9.84 kB
# Multi-Agent System Compliance Enforcement ## Overview This document defines the enforcement mechanisms, violation detection methods, and corrective procedures for the multi-agent workflow system. Compliance with the established protocols is mandatory and violations must be immediately corrected. ## ⚠️ ENFORCEMENT AUTHORITY ⚠️ **Primary Enforcement Agents**: - **@project-orchestrator-agent**: Overall system compliance monitoring - **@code-review-agent**: Code and implementation compliance - **@testing-agent**: Quality gate compliance - **All Agents**: Peer monitoring and self-reporting violations **Escalation Authority**: **@technical-architecture-agent** has final authority on compliance disputes ## Compliance Categories ### 1. Protocol Violations #### Task Tool Enforcement Violations **Rule**: All agent work MUST use Task tool invocation **Common Violations**: - Direct @agent-name mentions without Task tool - Orchestrator performing implementation work directly - Agents working without proper handoff **Detection Triggers**: - Agent performs work without visual activation marker - Code/files created without Task tool record - Missing handoff acknowledgment **Immediate Response**: ```markdown 🚨 PROTOCOL VIOLATION: Task Tool Bypass **Violating Agent**: @[agent-name] **Violation**: [Specific violation description] **Evidence**: [What was done incorrectly] ⛔ IMMEDIATE STOP WORK ORDER ⛔ **Required Actions**: 1. Stop all current work immediately 2. Revert any implementation work to pre-violation state 3. Initiate proper handoff using Task tool 4. Document violation in compliance log **Correct Procedure**: [Show proper Task tool usage] ``` #### Handoff Protocol Violations **Rule**: All handoffs must follow communication-protocol.md template **Common Violations**: - Incomplete handoff information - Missing success criteria or dependencies - No handoff acknowledgment from receiving agent - Skipping required visual markers **Detection Triggers**: - Agent begins work without acknowledgment - Missing handoff documentation - Incomplete context or requirements **Immediate Response**: ```markdown 🚨 HANDOFF VIOLATION: Incomplete Protocol **Violating Parties**: @[sender-agent] → @[receiver-agent] **Violation**: [Specific handoff issue] **Missing Elements**: [What was omitted] ⛔ WORK SUSPENSION ⛔ **Required Actions**: 1. Suspend all work on transferred task 2. Return task to sender for proper handoff 3. Complete full handoff template 4. Obtain proper acknowledgment before proceeding **Handoff Retry Required**: YES ``` ### 2. Role Boundary Violations #### Agent Scope Violations **Rule**: Agents MUST NOT perform work outside defined boundaries **Common Violations**: - Frontend agent doing backend work - Orchestrator writing code directly - Testing agent fixing bugs instead of reporting - Design agent implementing HTML/CSS **Detection Triggers**: - Agent creates files outside their scope - Work performed without appropriate specialist - Quality gates bypassed by wrong agent type **Immediate Response**: ```markdown 🚨 BOUNDARY VIOLATION: Role Overreach **Violating Agent**: @[agent-name] **Attempted Work**: [What work was performed] **Correct Agent**: @[appropriate-agent-name] ⛔ WORK NULLIFICATION ⛔ **Required Actions**: 1. Revert all work performed outside agent scope 2. Hand off task to appropriate specialist agent 3. Document violation and correct boundaries 4. Update agent boundaries if unclear **Work Status**: INVALID - Must be redone by appropriate agent ``` ### 3. Quality Gate Violations #### Quality Gate Bypass **Rule**: Quality gates CANNOT be skipped or circumvented **Common Violations**: - Deploying code without code review - Moving to production without security scan - Proceeding with failed test results - Skipping required documentation **Detection Triggers**: - Deployment without quality gate approvals - Code changes without review status - Missing test results or security clearance **Immediate Response**: ```markdown 🚨 QUALITY VIOLATION: Gate Bypass **Violating Agent**: @[agent-name] **Bypassed Gate**: [Which quality gate was skipped] **Risk Level**: [Critical/High/Medium] ⛔ IMMEDIATE ROLLBACK REQUIRED ⛔ **Required Actions**: 1. Stop all deployment/progression immediately 2. Rollback to last known good state 3. Complete ALL required quality gates 4. Re-validate entire change before proceeding **Deployment Status**: BLOCKED until all gates pass ``` ## Violation Detection Methods ### 1. Automated Detection **File Creation Monitoring**: - Track which agent created each file - Validate agent has authority for file type - Flag files created without Task tool record **Handoff Tracking**: - Monitor Task tool usage patterns - Detect missing acknowledgments - Identify incomplete handoff templates **Quality Gate Status**: - Track approval status for all work - Monitor for deployment without approvals - Alert on bypassed or incomplete reviews ### 2. Peer Monitoring **Agent Responsibilities**: - Report violations by other agents - Flag unclear or missing boundaries - Escalate compliance concerns immediately **Reporting Template**: ```markdown 📋 COMPLIANCE CONCERN REPORT **Reporting Agent**: @[reporter-name] **Target Agent**: @[target-agent] **Concern Type**: [Protocol/Boundary/Quality] **Description**: [Detailed description of concern] **Evidence**: [Supporting information] **Urgency**: [High/Medium/Low] **Recommended Action**: [Suggested resolution] ``` ### 3. Self-Reporting **Agent Responsibilities**: - Immediately report own violations - Stop work when boundary unclear - Request clarification before proceeding **Self-Report Template**: ```markdown 🔍 SELF-REPORTED VIOLATION **Agent**: @[agent-name] **Violation Type**: [What rule was broken] **Circumstances**: [How violation occurred] **Impact**: [What was affected] **Mitigation**: [Steps already taken] **Status**: Awaiting guidance for correction ``` ## Corrective Procedures ### 1. Minor Violations (Process) **Examples**: Missing visual markers, incomplete templates **Response Time**: Immediate correction **Authority**: Any peer agent can flag **Correction Steps**: 1. Flag violation and stop current work 2. Correct the process error 3. Resume work with proper procedures 4. Document lesson learned ### 2. Major Violations (Boundary/Quality) **Examples**: Role boundary violations, quality gate bypass **Response Time**: Immediate stoppage and rollback **Authority**: Enforcement agents + escalation **Correction Steps**: 1. Immediate work stoppage 2. Revert all violating work 3. Re-handoff to appropriate agent 4. Complete proper procedures 5. Document violation for process improvement ### 3. Critical Violations (Security/Safety) **Examples**: Security bypass, production deployment without approval **Response Time**: Emergency response protocol **Authority**: System architect + immediate escalation **Correction Steps**: 1. Emergency system protection 2. Immediate rollback/containment 3. Full incident response protocol 4. System-wide review and updates 5. Preventive measures implementation ## Compliance Tracking ### Violation Log Template ```markdown # Compliance Violation Log ## Violation #[Number] - [Date] **Type**: [Protocol/Boundary/Quality/Critical] **Violating Agent**: @[agent-name] **Rule Violated**: [Specific rule reference] **Detection Method**: [How violation was found] **Impact Assessment**: [What was affected] ### Timeline - **[Time]**: Violation occurred - **[Time]**: Violation detected - **[Time]**: Work stopped - **[Time]**: Corrective action completed - **[Time]**: Resolution verified ### Resolution **Actions Taken**: [List of corrective steps] **Work Status**: [Current state of affected work] **Lessons Learned**: [Process improvements identified] ### Prevention **Process Updates**: [Changes made to prevent recurrence] **Documentation Updates**: [Files modified] **Training Needed**: [Knowledge gaps identified] **Status**: [Open/Resolved/Under Review] ``` ### Compliance Metrics **Weekly Compliance Report**: - Total violations by type - Most common violation patterns - Agent compliance scores - Process improvement recommendations - Boundary clarification needs ## Emergency Escalation ### When to Escalate - Critical security or safety violations - Repeated violations by same agent - Unclear or conflicting boundaries - System-wide compliance breakdown ### Escalation Chain 1. **Peer Agent** → Report to enforcement agents 2. **Enforcement Agents** → Escalate to system architect 3. **System Architect** → Convene emergency decision council 4. **Decision Council** → System-wide corrective action ### Emergency Response Template ```markdown 🚨🚨 EMERGENCY COMPLIANCE ESCALATION 🚨🚨 **Escalation Level**: [1-4] **Issue**: [Brief description of critical problem] **Impact**: [What systems/processes are affected] **Risk**: [Potential consequences if not resolved] **Immediate Actions Taken**: [Emergency containment steps] **Decision Needed**: [What resolution is required] **Timeline**: [Urgency for resolution] @technical-architecture-agent - IMMEDIATE RESPONSE REQUIRED ``` ## Continuous Improvement ### Process Review Cycle - **Daily**: Monitor violation reports and immediate corrections - **Weekly**: Review compliance metrics and trends - **Monthly**: Analyze violation patterns and update procedures - **Quarterly**: Full system compliance audit and boundary review ### Improvement Triggers - Pattern of recurring violations - New agent types or capabilities - Technology or process changes - User feedback on system effectiveness This compliance enforcement system ensures the multi-agent workflow maintains high standards while providing clear, actionable correction procedures when violations occur.