DEV Community

Cover image for Deterministic Regeneration with ASA Core v1.0
vibecodiq
vibecodiq

Posted on • Originally published at vibecodiq.com

Deterministic Regeneration with ASA Core v1.0

Most AI-powered coding tools are excellent at generating code once
But they struggle — sometimes catastrophically — when asked to generate the same feature again.

You update the spec, click "regenerate," and suddenly:

  • Your custom logic disappears
  • Your validation rules vanish
  • Your test structure no longer matches
  • Your handlers and models drift apart

This is the regeneration trap.
ASA Core v1.0 was built specifically to escape it.

In this article, we'll break down:

  • Why regeneration fails in traditional tools
  • How ASA's deterministic pipeline prevents code loss
  • The slice-based architecture that eliminates drift
  • A real example showing safe regeneration
  • Why determinism is essential for multi-agent AI workflows

1. The Pain: Regeneration as a Full Rewrite

Here is the typical lifecycle developers experience with most generators:

Day 1: Generate scaffolding → looks great
Day 2: Implement business logic → feels great
Day 3: Requirement changes → regenerate → everything is gone
Enter fullscreen mode Exit fullscreen mode

The generator doesn't know what you wrote.
It only knows how to produce a new skeleton.

This leads to:

  • Lost developer time
  • Fear of touching generators
  • Divergent specs & code
  • Architecture decay

You don't just lose code — you lose trust.


2. ASA's Model: Slices, Specs, and Contracts

ASA uses three layers to create a deterministic, AI-safe workflow:

1. Slices

Self-contained vertical feature units:

domains/auth/login/
├── slice.spec.md
├── slice.contract.json
├── handler.py
├── service.py
├── repository.py
├── schemas.py
└── tests/
Enter fullscreen mode Exit fullscreen mode

2. Specs (Human-readable)

Seven required sections: Purpose, Inputs, Outputs, Behaviour, Errors, Side Effects, Dependencies.

3. Contracts (Machine-readable)

JSON schema generated from the spec:

{
  "inputs": { "email": "string", "password": "string" },
  "outputs": { "jwt_token": "string", "expires_in": "int" }
}
Enter fullscreen mode Exit fullscreen mode

ASA then uses deterministic templates to generate code.

No randomness.
No heuristics.
No AI in the core pipeline.


3. Marker-Based Code Preservation (ASA's Key Feature)

Instead of trying to guess what is "your code" vs "generated code", ASA explicitly marks regions to preserve:

# === BEGIN USER CODE ===
def execute(self, request: LoginRequest) -> LoginResponse:
    user = self.repo.get_user_by_email(request.email)
    token = self.repo.generate_jwt(user.id)
    return LoginResponse(jwt_token=token, expires_in=3600)
# === END USER CODE ===
Enter fullscreen mode Exit fullscreen mode

During regeneration, ASA:

  1. Extracts everything inside the markers
  2. Regenerates the structure around it
  3. Inserts your code back exactly where it belongs

This is a 100% deterministic round trip.

Your code can never be overwritten by accident.


4. Example: Login Slice with New Requirements

You have a working login slice.

Later, security wants to log ip_address.

In most tools:

Regenerate → code loss → manual merge → bugs.

In ASA:

  1. Update slice.spec.md:
- email: string
- password: string
- ip_address: string # new
Enter fullscreen mode Exit fullscreen mode
  1. Regenerate safely:
asa generate-contract auth/login
asa regenerate-slice auth/login
Enter fullscreen mode Exit fullscreen mode

ASA updates:

  • Models
  • Handler signature
  • Tests
  • Contract

Your logic remains intact.


5. Determinism Enables AI-First Engineering

In AI-assisted development, regeneration must be safe because:

  • Multiple agents may touch the same slice
  • Specs may change daily
  • Contracts evolve quickly
  • Automated workflows need predictable behavior
  • CI needs to regenerate and lint without human supervision

ASA ensures:

  • Same spec → same contract
  • Same contract → same files
  • No surprises in diffs
  • No accidental overwrite of logic

This is architecture built for the AI era.


6. Why Teams Adopt ASA

ASA Core v1.0 is perfect for:

  • Long-lived backends
  • Multi-agent coding environments
  • Fast-evolving feature sets
  • Teams tired of code drift
  • Organizations needing deterministic output
  • Anyone building with LLMs at the center

ASA allows you to embrace regeneration — not fear it.


Conclusion

Regeneration should NOT feel like:

rm -rf my_code
Enter fullscreen mode Exit fullscreen mode

It should feel like:

safely update the structure while preserving my logic
Enter fullscreen mode Exit fullscreen mode

ASA Core v1.0 makes that possible using:

  • Slice colocation
  • Deterministic templates
  • Machine-readable contracts
  • Marker-based preservation
  • Boundary enforcement via linter

If you want a backend architecture that can keep up with AI-driven development — ASA is it.

Source code & starter kit: https://github.com/vibecodiq/asa-starter-kit

Top comments (0)