Mahmya, a developer infrastructure platform, has published a rigorous 22-step protocol for integrating AI-generated code, arguing that fast but slightly wrong code is the most expensive kind of technical debt. The framework, detailed in a blog post dated December 2, 2026, mandates that every change pass through three distinct phases—decide, build, and land—each ending in a hard gate where work stops until specific checks pass. This structure is designed to combat 'architectural drift,' a phenomenon where stateless AI agents, lacking memory of previous decisions, implement the same business rule in conflicting ways.
The Three-Phase Gate System
The process begins with Phase 1, 'Decide on Paper,' which covers steps 1 through 7 and strictly forbids writing any code. During this phase, an agent drafts a position paper and design record, which are reviewed by a different model family before a human owner makes the final decision. The gate here is the owner’s approval to start the build, ensuring that the design is validated before any implementation effort is wasted. This separation aims to fix wrong ideas on paper, costing one page, rather than in code, where fixes can take days. Phase 2, 'Build and Review,' is an iterative loop covering steps 8 through 15. A writer agent builds on a single branch, while automated gates run on a fresh database to prevent data contamination from previous runs. Crucially, the reviewer must come from a different model family than the writer to avoid shared blind spots. If the review verdict is 'not yet,' the writer must fix the entire class of defect and add a test. If a component fails three times, the scope is cut and recorded for the owner, preventing endless patch cycles on fundamentally flawed designs. The final stage, Phase 3 'Land and Prove,' spans steps 16 through 22. Here, the integrator agent verifies the diff, and a full test suite of approximately 13,000 tests runs against the merged code. The design remains in a 'proposed' state until a real-world proof run succeeds and the human owner pushes the changes to the shared repository. This final human gate ensures that the most irreversible step—pushing to main—is taken by a person, not an agent, providing a last line of defense against catastrophic failures.
Combating Stateless Agent Amnesia
The core problem Mahmya addresses is the lack of persistent memory in current AI agents. The source material illustrates this with an example where three agents, given the same business rule, implement it in three different places: one in the service layer, one in the UI, and one in both. While each implementation might pass its own local tests, the system ends up disagreeing with itself. The 22-step process acts as externalized shared memory, forcing decisions to be written down in files that subsequent agents must read and adhere to. The workflow explicitly assigns roles to minimize human bottlenecking while maximizing safety. Out of the 22 steps, the human owner performs only four, while AI agents and scripts handle the other 18. The 'Integrator' agent supervises the process, making decisions and verifying merges, but it never reviews its own work. This strict separation of duties, combined with the requirement for cross-vendor model reviews, creates a system where no single agent can blindly trust its own output.
Key Takeaways
- Speed is not the goal: The protocol accepts slower individual change delivery to ensure platform stability and prevent architectural drift.
- Model diversity is mandatory: The writer and reviewer must come from different model families to catch logic and security holes that a single family might miss.
- State lives in files, not memory: When an agent crashes or hits a quota limit, the next agent resumes from the state on disk (branches, status files, logs), ensuring continuity.
- Human ownership of irreversible actions: Only the human owner can push code to the shared main branch, keeping the final authority with a person.
The Bottom Line
For builders deploying AI agents in production, this framework offers a sobering reality check: without strict, file-based governance and cross-model verification, 'fast' code is just a faster route to systemic incoherence. The 22-step process is not bureaucracy; it is the cost of doing business with stateless intelligence.