Inspiration

AI coding agents are becoming increasingly capable of modifying real software repositories. However, autonomous code changes introduce a critical problem: how do we know that an AI-generated change is actually safe?

A patch can look correct but still introduce regressions, fail under real conditions, or break existing functionality. I wanted to build a system where an AI-generated solution is not trusted simply because it was produced by an AI.

This led me to build PACT — Proof-Carrying Autonomous Change.

The idea is simple: an autonomous coding agent should not only make a change—it should provide evidence that the change works and include a safety mechanism to undo the change when verification fails.

What I Built

PACT is an autonomous software engineering agent that takes a software problem described in natural language and executes an end-to-end code repair workflow.

The PACT pipeline:

  1. Creates a structured mission from the developer's request.
  2. Scans and understands the target codebase.
  3. Runs baseline tests to collect evidence.
  4. Uses AI reasoning to identify the root cause.
  5. Creates a structured patch plan.
  6. Generates an exact code patch.
  7. Creates backups of the original files.
  8. Applies the generated patch.
  9. Runs verification tests against the modified code.
  10. If verification succeeds, PACT produces proof of the successful change.
  11. If verification fails, PACT automatically rolls back the patch and restores the original code.

My demonstration focuses on a duplicate checkout race condition where concurrent checkout requests can create multiple orders for the same user and product. PACT analyzes the issue, identifies the concurrency problem, generates a database-level fix with appropriate error handling, applies the change, and verifies the result.

I also built a deliberate failure-injection mode to demonstrate PACT's safety boundary. When verification is intentionally made to fail, PACT detects the failure and automatically restores the original code from the backup.

Why It Matters

Most autonomous coding systems focus primarily on generating code. PACT focuses on the complete lifecycle of an autonomous change:

Understand → Plan → Change → Verify → Prove → Roll Back if Necessary

This makes autonomous software modification more trustworthy and auditable.

The core principle behind PACT is:

AI should not just change your code. It should prove the change is safe.

What I Learned

Building PACT taught me that autonomous coding is not only an AI problem. The difficult part is building a reliable engineering loop around the AI.

Through this project, I learned the importance of:

  • Separating AI reasoning from deterministic execution.
  • Using tests as objective verification evidence.
  • Protecting original files with backups before modification.
  • Treating generated patches as untrusted until verified.
  • Designing automatic rollback as a safety boundary.
  • Building clear proof and evidence into the user experience.

I also learned that a successful autonomous software agent must combine AI capabilities with traditional software engineering principles such as testing, isolation, backups, and recovery.

Challenges I Faced

One of the biggest challenges was making the system robust when AI-generated patches are imperfect or when external AI services are unavailable.

To address this, I designed the architecture with separate components for reasoning, patch planning, patch generation, patch application, test execution, and rollback. I also implemented a deterministic local fallback for the demonstration scenario.

Another challenge was safely handling concurrent database operations. The demonstration required addressing a race condition where two simultaneous requests could both pass an initial existence check before creating duplicate orders. The solution uses a database-level uniqueness constraint combined with transaction error handling.

The final result is a working prototype that demonstrates how AI-driven software engineering can move beyond code generation toward verifiable and reversible autonomous change.

Built With

Share this project:

Updates