🚨 MANDATORY validation step for all background agents before indicating completion.
(
arguments: dict[str, Any], project_root: Path
)
| 1637 | |
| 1638 | |
| 1639 | async def validate_completion( |
| 1640 | arguments: dict[str, Any], project_root: Path |
| 1641 | ) -> CallToolResult: |
| 1642 | """🚨 MANDATORY validation step for all background agents before indicating completion.""" |
| 1643 | task_description = arguments.get("task_description", "Code changes") |
| 1644 | run_full_test_suite = arguments.get("run_full_test_suite", True) |
| 1645 | |
| 1646 | result_text = f"# 🚨 COMPLETION VALIDATION FOR: {task_description}\n\n" |
| 1647 | result_text += "## MANDATORY PRE-COMPLETION CHECK\n\n" |
| 1648 | result_text += ( |
| 1649 | "This tool MUST be run by all background agents before indicating completion.\n" |
| 1650 | ) |
| 1651 | result_text += "Running comprehensive test suite to ensure all changes are working correctly.\n\n" |
| 1652 | |
| 1653 | validation_failed = False |
| 1654 | |
| 1655 | # First, validate Arduino.h includes |
| 1656 | result_text += "### Validating Arduino.h Includes\n\n" |
| 1657 | try: |
| 1658 | arduino_validation = await validate_arduino_includes( |
| 1659 | { |
| 1660 | "directory": "src", |
| 1661 | "include_examples": False, |
| 1662 | "check_dev": False, |
| 1663 | "show_approved": False, |
| 1664 | }, |
| 1665 | project_root, |
| 1666 | ) |
| 1667 | |
| 1668 | if arduino_validation.isError: |
| 1669 | validation_failed = True |
| 1670 | result_text += "[ERROR] **ARDUINO.H VALIDATION FAILED**\n\n" |
| 1671 | result_text += "New Arduino.h includes detected! This violates FastLED coding standards.\n" |
| 1672 | result_text += "Please remove Arduino.h includes and use FastLED's platform abstractions instead.\n\n" |
| 1673 | else: |
| 1674 | result_text += "[OK] **Arduino.h validation passed**\n\n" |
| 1675 | |
| 1676 | except Exception as e: |
| 1677 | result_text += f"⚠️ **Arduino.h validation error:** {str(e)}\n\n" |
| 1678 | |
| 1679 | if run_full_test_suite: |
| 1680 | result_text += "### Running Full Test Suite: `bash test`\n\n" |
| 1681 | |
| 1682 | try: |
| 1683 | # Run the bash test command as specified in user rules |
| 1684 | test_result = await run_command(["bash", "test"], project_root) |
| 1685 | |
| 1686 | # Check if tests passed by looking for common failure indicators |
| 1687 | if ( |
| 1688 | "FAILED" in test_result |
| 1689 | or "ERROR" in test_result |
| 1690 | or "error:" in test_result.lower() |
| 1691 | ): |
| 1692 | validation_failed = True |
| 1693 | result_text += ( |
| 1694 | "[ERROR] **VALIDATION FAILED - TESTS CONTAIN ERRORS**\n\n" |
| 1695 | ) |
| 1696 | result_text += "```\n" + test_result + "\n```\n\n" |
no test coverage detected