Inspiration

Engineering teams often ship code that is functionally correct but performance-blind, only discovering latency spikes or CPU bottlenecks once they hit production traffic. We wanted to eliminate the "performance tax" and the hours spent diagnosing regressions by creating an AI teammate that catches these issues during the peer-review process.

What it does

Matou.ai is an autonomous "Docking Agent" that plugs into GitLab to catch performance problems before they reach production. The moment a merge request is opened, it spins up twin Kubernetes environments (main vs. MR branch), subjects both to identical load tests using k6, and uses Gemini AI to correlate telemetry data with the git diff to identify exactly which line of code caused a regression.

How we built it

The system is orchestrated by a FastAPI backend that handles GitLab webhooks and manages a complex pipeline across several services:

  • Google Kubernetes Engine (GKE): To host the side-by-side shadow environments and k6 load runners.
  • GCP Cloud Monitoring: To collect real-time CPU and memory telemetry.
  • Gemini AI (Vertex AI): To perform root cause analysis by reading the metrics and code diff together.
  • React + Ink: To power a real-time CLI dashboard that streams pipeline stages via SSE.

Challenges we ran into

One of the primary hurdles was synchronizing the infrastructure lifecycle with metric ingestion, specifically waiting for the ~15-second propagation delay in Cloud Monitoring to ensure we had accurate time-series data for both pods. We also had to ensure that the load testing environment was perfectly identical for both the main and MR branches to prevent "noisy neighbor" effects from skewing the performance delta.

Accomplishments that we're proud of

We successfully built a zero-setup workflow where developers don't need to install an SDK or change their process—the agent simply comments on the GitLab MR. We are also proud of the Insight Engine, which allows Gemini to act as a performance expert, moving beyond simple numbers to suggest specific code fixes, like replacing a heavy loop with a dictionary lookup.

What we learned

Building this taught us the power of "shifting performance left" and how AI can be used not just to write code, but to provide context-aware infrastructure analysis. We learned how to tightly orchestrate ephemeral GKE namespaces and how to effectively prompt Gemini to correlate high-level telemetry data with low-level git patches.

What's next for MatouAI

The next steps involve expanding support beyond GitLab to GitHub and Bitbucket, and implementing "Health Checks" for push events that compare new code against a saved historical baseline. We also plan to refine the k6 load generation to automatically mirror actual production traffic patterns for even more realistic shadow testing.

Built With

Share this project:

Updates