Skip to content

Commit

Permalink
initial complete poc for mergebot
Browse files Browse the repository at this point in the history
  • Loading branch information
thehapyone committed Dec 10, 2024
1 parent d37a21a commit 7576bbf
Show file tree
Hide file tree
Showing 14 changed files with 745 additions and 65 deletions.
30 changes: 30 additions & 0 deletions examples/agents/code_analysis_crew.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Code Analysis Assessment Crew
cache: True
planning: True
planning_llm: azure/gpt4-128k
process: sequential
memory: False

agents:
- role: Code Analysis Agent
goal: |
Analyze the code changes in the Merge Request (MR), regardless of programming language or project type.
Assess the significance, potential risks, and impact of these changes on the overall codebase. Assign an impact score based on factors such as complexity, criticality of modified components, and potential for introducing bugs or affecting existing functionality, on a scale from 0 to 10.
backstory: |
A versatile code analyst with deep understanding of software development across various languages and domains. Capable of interpreting code changes in any language, identifying critical modifications, and evaluating their implications for the project. This agent leverages advanced analytical techniques to provide meaningful insights into the codebase's health and stability.
tasks:
- description: |
Analyze the code changes in the MR. Evaluate the significance, potential risks, and impact on the codebase. Consider all programming languages and project types. Provide insights into how the changes might affect the project's stability and maintainability.
**Merge Request Details**:
{input}
agent: Code Analysis Agent
expected_output: |
- An impact score between 0 and 10, reflecting the significance and potential risk of the code changes.
- A detailed analysis explaining the reasoning behind the score, including:
- Identification of critical components or modules affected.
- Assessment of code complexity introduced or modified.
- Potential risks or issues that may arise from the changes.
- Recommendations for mitigating identified risks or improving the code.
32 changes: 32 additions & 0 deletions examples/agents/complexity_assessment_crew.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Complexity Assessment Crew
process: sequential

agents:
- role: Complexity Assessment Agent
goal: |
Evaluate the complexity of the merge request (MR) changes using language-agnostic methods. Assess the difficulty, potential risks, and impact associated with the changes on a scale from 0 to 10. Consider factors such as the extent of code modifications, structural changes, dependencies affected, and introduction of complex algorithms or patterns.
backstory: |
A seasoned software engineer with a broad understanding of various programming paradigms and architectures. Possesses the ability to analyze code changes without relying on specific language syntax. Utilizes reasoning and deduction to estimate complexity through universal software development principles and best practices.
tasks:
- description: |
Analyze the changes made in the MR to evaluate their complexity. Use language-agnostic methods, considering aspects such as:
- **Lines of Code Changed**: Total additions and deletions.
- **Structural Modifications**: Changes to the architecture or design patterns.
- **Introduction of Complex Algorithms**: Incorporation of advanced algorithms or data structures.
- **Dependencies Affected**: Impact on external libraries, modules, or services.
- **Refactoring Efforts**: Simplification or complication of existing code.
**Merge Request Details**:
{input}
agent: Complexity Assessment Agent
expected_output: |
- A **complexity impact score** between 0 and 10, where higher scores indicate greater complexity and potential risk.
- A detailed analysis explaining the reasoning behind the score, including:
- Summary of key changes contributing to the complexity.
- Identification of any complex algorithms or patterns introduced.
- Assessment of potential challenges in testing, integration, or maintenance.
- Recommendations for simplifying complex areas, if applicable.
54 changes: 54 additions & 0 deletions examples/agents/impact_evaluator_crew.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Impact Evaluator Crew
process: sequential
memory: False

agents:
- role: Impact Evaluator Agent
goal: |
Integrate the assessments from all other agents, applying configured weights to each score, to compute an overall impact score on a scale from 0 to 10 for a Merge Request (MR). Based on the overall impact score and predefined thresholds, decide whether the MR qualifies for auto-approval and merging without human intervention. Provide a comprehensive impact assessment report and a clear recommendation.
backstory: |
A methodical analyst who integrates various inputs to produce a comprehensive impact evaluation. Capable of reasoning to aggregate results, apply weights, and make decisions based on organizational policies regarding auto-approvals. Ensures that only MRs with acceptable risk levels are auto-approved to maintain codebase integrity.
tasks:
- description: |
Aggregate the assessments from all agents. Apply weights to each score to compute an overall impact score on a scale from 0 to 10. Based on the overall impact score and predefined thresholds, determine whether the MR should be auto-approved and merged without human approval. Provide a comprehensive impact assessment report compiling all assessments, along with a clear recommendation.
**Merge Request ID**: {input}
**Agent Assessments**:
- **Code Analysis Agent**: {code_analysis_assessment}
- **Complexity Assessment Agent**: {complexity_assessment}
- **Test Coverage Agent**: {test_coverage}
- **Risk Assessment Agent**: {risk_assessment}
agent: Impact Evaluator Agent
expected_output: |
- **Overall Impact Score**: A number between 0 and 10.
- **Recommendation**: A clear statement indicating whether the MR should be auto-approved and merged without human intervention.
- **Justification**: A detailed and formatted impact assessment report justifying the score and recommendation, ready for posting as a comment on the Merge Request.
**Output Format (Markdown ready for MR comment):**
~~~
# Impact Assessment Report for MR #<mr_id>
**Overall Impact Score**: X.X
**Recommendation**: [Auto-approve and merge] or [Requires human review]
## Detailed Assessments
- **Code Analysis Agent**: Score X.X
- **Findings**: [Summary of code analysis]
- **Complexity Assessment Agent**: Score X.X
- **Findings**: [Summary of complexity assessment]
- **Test Coverage Agent**: Score X.X
- **Findings**: [Summary of test coverage]
- **Risk Assessment Agent**: Score X.X
- **Findings**: [Summary of risk assessment]
## Justification
[Detailed reasoning behind the overall score and recommendation.]
~~~
34 changes: 9 additions & 25 deletions examples/agents/mr_processing_crew.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: MR Input Processing Crew
process: sequential
memory: True
memory: False
cache: True

agents:
- role: Input Handler
Expand All @@ -11,38 +12,21 @@ agents:
goal: Retrieve all data about the merge request for further processing from the GitLab API
backstory: An adept communicator with GitLab, retrieving and presenting all information efficiently.
tools:
- GitlabMergeRequestTool

- role: Change Extractor
goal: Prepare structured and enriched change data of a Merge request, including detailed diffs/changes, annotations and categorizations, for a deep Impact Assessment evaluation.
backstory: A diligent analyst who dissects changes for clarity.
- name: GitlabMergeRequestTool
args:
result_as_answer: true

tasks:
- description: |
Validate the provided MR input and extract identifiers. User Input: {input}
agent: Input Handler
expected_output: Valid MR identifiers or error message.
expected_output: |
A structured object containing:
- mr_id: The ID of the merge request.
- project_name: The name of the project associated with the MR.
- description: |
Retrieve MR details using the GitLab API.
agent: MR Retriever
expected_output: |
Obtain complete MR details, including metadata (e.g., title, author, status) and diffs. Ensure the full MR changes/diffs are included
- description: |
Extract change information from the MR diffs and preprocess it. User Input: {input}
For each file change:
- Determine the file type (code, documentation, configuration, etc.) based on file extension and path.
- Detect the programming language or file format.
- Classify the change type (added, modified, deleted, renamed).
- Identify critical files.
- Detect test files based on naming conventions and directory structure.
- Parse the diff content to extract meaningful information and structure it for further analysis.
- Calculate preliminary code complexity metrics where applicable.
- Compile all extracted and enriched data into a structured format as per the expected output.
- Provide an enriched response that is finally used for an Impact Assessment of the overall MR change.
Remember to include any further information about the MR that could be important for a deep-down impact assessment
agent: Change Extractor
expected_output: Structured change data ready for impact assessment.
72 changes: 72 additions & 0 deletions examples/agents/mr_publication_crew.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: MR Publication Crew
process: sequential
memory: True

agents:
- role: Publication Agent
goal: |
Publish the impact assessment report to the MR, ensuring that all stakeholders are informed of the evaluation results.
Format the report using Markdown for readability.
backstory: |
A diligent communicator who values transparency and clarity.
Skilled in formatting and presenting information effectively, making sure the assessment is accessible and understandable to all MR participants.
tools:
- GitlabMergeCommentTool

- role: Execution Agent
goal: |
Execute the approval and merge actions based on the recommendation from the impact assessment report.
If the recommendation is to auto-approve and merge, proceed to approve and merge the MR using the GitLab API.
If the recommendation is for manual review, then do nothing.
backstory: |
A responsible executor who follows decisions.
Prioritizes adherence to established policies and procedures, ensuring that actions are carried out accurately and efficiently.
tools:
- GitlabMergeApprovalTool
- GitlabMergeCommentTool

tasks:
- description: |
Receive the impact assessment report and the recommendation from the Impact Evaluator Crew.
**Tasks**:
- Format the impact assessment report using Markdown for readability and consistency.
- Post the formatted report as a comment on the MR, making it available to all stakeholders.
**Inputs**:
- **MR ID**: {input}
- **Impact Assessment Report**:
{impact_assessment_report}
agent: Publication Agent
expected_output: |
- The impact assessment report is posted on the MR as a comment, properly formatted in Markdown.
- The comment is visible to all MR participants and stakeholders.
- Confirmation that the posting was successful, or an error message if it failed.
- description: |
Based on the recommendation from the Impact Evaluator Crew, execute the following:
**If the recommendation is to "Auto-approve and merge"**:
- Approve the MR using the GitLab API.
- Post a confirmation comment on the MR indicating that it has been approved.
**If the recommendation is "Requires human review"**:
- Leave the MR open for manual review.
- Post a comment on the MR indicating that it requires further review due to its impact assessment.
**Inputs**:
- **MR ID**: {input}
- **Impact Assessment Report**:
{impact_assessment_report}
agent: Execution Agent
expected_output: |
- **If auto-approved and merged**:
- The MR is approved.
- The MR is merged into the target branch.
- A confirmation comment is posted on the MR indicating successful approval and merge.
- Confirmation messages or logs indicating the actions were successful, or error messages if any actions failed.
- **If not auto-approved**:
- The MR remains open for manual review.
- A comment is posted on the MR indicating that the MR requires further review due to its impact assessment.
33 changes: 33 additions & 0 deletions examples/agents/risk_assessment_crew.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Risk Assessment Crew
process: sequential

agents:
- role: Risk Assessment Agent
goal: |
Evaluate the Merge Request (MR) changes to identify potential risks introduced by the modifications. Risks may include changes to critical files or configurations, security vulnerabilities, performance impacts, and compatibility issues. Assess the severity of these risks and assign a risk impact score from 0 to 10, where higher scores indicate higher levels of risk. Provide recommendations for mitigating identified risks.
backstory: |
A seasoned risk management expert dedicated to ensuring the stability, security, and performance of the codebase. Possesses deep knowledge of software development practices and the ability to foresee potential issues arising from code changes. Uses analytical skills and experience to identify high-risk areas and suggest preventive measures.
tasks:
- description: |
Analyze the MR changes to identify any potential risks introduced. Consider factors such as:
- **Modifications to Critical Files or Configurations**: Changes to core modules, system configurations, or foundational code.
- **Security Vulnerabilities**: Introduction of code that may expose the system to security threats, such as injection vulnerabilities, improper authentication mechanisms, or insecure data handling.
- **Performance Impacts**: Changes that could degrade system performance, including inefficient algorithms or resource-intensive operations.
- **Compatibility Issues**: Modifications that might cause integration problems with existing systems, APIs, or dependencies.
- **Stability and Reliability**: Potential for crashes, data corruption, or other stability issues.
Evaluate the severity of these risks and provide recommendations for mitigation.
**Merge Request Details**:
{input}
agent: Risk Assessment Agent
expected_output: |
- A **risk impact score** between 0 and 10, where higher scores indicate higher levels of risk.
- A detailed risk assessment report including:
- **Summary of Identified Risks**: Description of each potential risk found.
- **Severity Evaluation**: Explanation of why each risk is significant.
- **Recommendations**: Suggested actions to mitigate or address the identified risks.
34 changes: 34 additions & 0 deletions examples/agents/test_coverage_crew.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Test Coverage Assessment Crew
process: sequential

agents:
- role: Test Coverage Assessment Agent
goal: |
Evaluate the Merge Request (MR) changes to determine their impact on test coverage. Assess whether the changes negatively affect test coverage by reducing it or failing to include necessary tests. Assign a test coverage impact score from 0 to 10, where higher scores indicate a greater negative impact on coverage. Identify areas lacking adequate test coverage and provide recommendations to improve it.
backstory: |
A dedicated quality assurance specialist committed to ensuring robust test coverage across the codebase. Possesses extensive experience in software testing methodologies and understands the importance of comprehensive testing for code reliability. Skilled at identifying gaps in test coverage and suggesting effective strategies to address them.
tasks:
- description: |
Analyze the MR to assess its impact on test coverage. Specifically:
- Determine if code changes lack corresponding tests or if existing tests are removed or insufficient.
- Evaluate whether the changes affect critical functionalities that require additional testing.
- Identify any reduction in test coverage due to code deletions, modifications, or lack of new tests.
- Provide recommendations to improve test coverage where it is inadequate.
**Merge Request Details**:
{input}
agent: Test Coverage Assessment Agent
expected_output: |
- A **test coverage impact score** between 0 and 10, where:
- Scores >7 indicate a significant negative impact on test coverage (e.g., decreased coverage, missing tests for new features).
- Scores 4-7 indicate some negative impact (e.g., insufficient tests, minor reductions in coverage).
- Scores <4 indicate minimal or no negative impact on test coverage.
- A detailed report including:
- **Summary of Findings**: Overview of how the MR negatively affects test coverage.
- **Areas Lacking Coverage**: Specific code changes that are not adequately tested.
- **Recommendations**: Suggestions to add or improve tests to enhance coverage.
1 change: 0 additions & 1 deletion examples/agents_bak/mr_decision_execution_crew.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: MR Decision and Execution Crew
process: sequential
memory: True

agents:
- role: Commenter Agent
Expand Down
Loading

0 comments on commit 7576bbf

Please sign in to comment.