The current multi-agent execution pipeline in AutoMaintainer exhibits five core functional limitations during autonomous repository maintenance:
Single-File Hardcoding: Agents can only write a single root file (feature_issue_X.py) and cannot edit existing multi-file projects or subdirectories.
Untested PR Merging: Code review relies purely on LLM text inspection without executing unit test suites (pytest or npm test).
Stateless Execution: Agents start with zero memory across runs, leading to duplicate feature proposals or repeating previously rejected ideas.
Minimal PR Descriptions: Generated GitHub Pull Requests contain generic one-line bodies ("This PR resolves #X").
Local Workspace Desynchronization: The local repository in /tmp remains on main branch when feature branches are created on GitHub.
This issue proposes a comprehensive 5-part architectural enhancement to transform AutoMaintainer into a production-grade, test-driven autonomous software engineering team.
Detailed Problems & Proposed Solutions
- Multi-File Precision Editing & Unified Git Diff Engine
Problem: Implementer agent replaces entire file contents and is restricted to a single filename in the root directory. It cannot edit existing files across nested subdirectories.
Proposed Solution: Build a Unified Git Diff Patching Engine (apply_unified_diff_patch) in backend/agents.py:
Parses standard unified diff format (--- a/file \n +++ b/file \n @@ ... @@).
Applies patches locally via git apply --whitespace=fix.
Leverages git status --porcelain to detect all modified/added files across subdirectories and commit them to the PR in a single commit.
- Automated Test Execution Node (Test-Driven AI Development)
Problem: Maintainer agent approves PRs based on visual LLM review alone, risking merging code that breaks existing functionality.
Proposed Solution: Implement an automated test runner (run_repo_tests) in maintainer_node:
Detects Python (pytest / unittest) and Node.js (npm test) test runners inside /tmp/<repo_dir> with a 15-second timeout safeguard.
Passes test stdout/stderr stack traces directly into the Maintainer agent prompt.
Automatically rejects PRs if tests fail and routes failure logs back to the Implementer to fix bugs prior to merging.
- Historical Repository Memory Bank (Cross-Run Context Persistence)
Problem: Each agent run executes statelessly, resulting in duplicate feature proposals or repeating ideas that were rejected in earlier runs.
Proposed Solution: Implement a persistent JSON memory bank (RepositoryMemoryBank) stored in backend/memory.json:
Tracks historical architectural directives, merged PR numbers, and previously rejected ideas (with PM review reasons).
Injects memory context into the Architect and Visionary agent prompts, explicitly forbidding duplicate feature proposals.
- Automated Rich PR Summaries & Risk Assessment
Problem: Pull Requests created by the agent contain uninformative one-line bodies ("This PR resolves #X").
Proposed Solution: Implement generate_rich_pr_body in backend/agents.py to generate structured Markdown descriptions containing:
📋 Executive Summary: What was built and why.
📁 File Impact Breakdown: List of modified files.
⚠️ Risk Assessment: Low/Medium/High risk rating and breaking change alerts.
🧪 Manual Verification Steps: Step-by-step test instructions for human reviewers.
- Local Git Workspace Branch Synchronization
Problem: When a new feature branch is created via PyGithub, the local clone in /tmp/<repo_dir> remains on the main branch, making local code indexers and AST tools out of sync.
Proposed Solution: Update implementer_node to execute git fetch origin and git checkout -B <branch_name> origin/<branch_name> in /tmp/<repo_dir> prior to local file synchronization.
Acceptance Criteria
Multi-File Patching: The Implementer must successfully parse unified git diffs and update files across multiple subdirectories in a single PR.
Test-Driven Merging: PR merging must require 100% passing test suite execution; failing tests must trigger an automated fix iteration loop.
Memory Context: The Visionary agent must avoid proposing duplicate features recorded in backend/memory.json.
Rich PR Body: All created PRs must contain Executive Summary, File Impact, Risk Assessment, and Manual Verification sections.
Branch Sync: The local workspace directory must switch to the active feature branch during agent execution.
The current multi-agent execution pipeline in AutoMaintainer exhibits five core functional limitations during autonomous repository maintenance:
Single-File Hardcoding: Agents can only write a single root file (feature_issue_X.py) and cannot edit existing multi-file projects or subdirectories.
Untested PR Merging: Code review relies purely on LLM text inspection without executing unit test suites (pytest or npm test).
Stateless Execution: Agents start with zero memory across runs, leading to duplicate feature proposals or repeating previously rejected ideas.
Minimal PR Descriptions: Generated GitHub Pull Requests contain generic one-line bodies ("This PR resolves #X").
Local Workspace Desynchronization: The local repository in /tmp remains on main branch when feature branches are created on GitHub.
This issue proposes a comprehensive 5-part architectural enhancement to transform AutoMaintainer into a production-grade, test-driven autonomous software engineering team.
Detailed Problems & Proposed Solutions
Problem: Implementer agent replaces entire file contents and is restricted to a single filename in the root directory. It cannot edit existing files across nested subdirectories.
Proposed Solution: Build a Unified Git Diff Patching Engine (apply_unified_diff_patch) in backend/agents.py:
Parses standard unified diff format (--- a/file \n +++ b/file \n @@ ... @@).
Applies patches locally via git apply --whitespace=fix.
Leverages git status --porcelain to detect all modified/added files across subdirectories and commit them to the PR in a single commit.
Problem: Maintainer agent approves PRs based on visual LLM review alone, risking merging code that breaks existing functionality.
Proposed Solution: Implement an automated test runner (run_repo_tests) in maintainer_node:
Detects Python (pytest / unittest) and Node.js (npm test) test runners inside /tmp/<repo_dir> with a 15-second timeout safeguard.
Passes test stdout/stderr stack traces directly into the Maintainer agent prompt.
Automatically rejects PRs if tests fail and routes failure logs back to the Implementer to fix bugs prior to merging.
Problem: Each agent run executes statelessly, resulting in duplicate feature proposals or repeating ideas that were rejected in earlier runs.
Proposed Solution: Implement a persistent JSON memory bank (RepositoryMemoryBank) stored in backend/memory.json:
Tracks historical architectural directives, merged PR numbers, and previously rejected ideas (with PM review reasons).
Injects memory context into the Architect and Visionary agent prompts, explicitly forbidding duplicate feature proposals.
Problem: Pull Requests created by the agent contain uninformative one-line bodies ("This PR resolves #X").
Proposed Solution: Implement generate_rich_pr_body in backend/agents.py to generate structured Markdown descriptions containing:
📋 Executive Summary: What was built and why.
📁 File Impact Breakdown: List of modified files.
🧪 Manual Verification Steps: Step-by-step test instructions for human reviewers.
Problem: When a new feature branch is created via PyGithub, the local clone in /tmp/<repo_dir> remains on the main branch, making local code indexers and AST tools out of sync.
Proposed Solution: Update implementer_node to execute git fetch origin and git checkout -B <branch_name> origin/<branch_name> in /tmp/<repo_dir> prior to local file synchronization.
Acceptance Criteria
Multi-File Patching: The Implementer must successfully parse unified git diffs and update files across multiple subdirectories in a single PR.
Test-Driven Merging: PR merging must require 100% passing test suite execution; failing tests must trigger an automated fix iteration loop.
Memory Context: The Visionary agent must avoid proposing duplicate features recorded in backend/memory.json.
Rich PR Body: All created PRs must contain Executive Summary, File Impact, Risk Assessment, and Manual Verification sections.
Branch Sync: The local workspace directory must switch to the active feature branch during agent execution.