Deterministic Regeneration with ASA Core v1.0
Source: Dev.to
Regeneration trap
Most AI‑powered coding tools are excellent at generating code once… 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.
Why regeneration fails in traditional tools
The generator doesn’t know what you wrote. The typical lifecycle looks like:
- Day 1 – Generate scaffolding → looks great
- Day 2 – Implement business logic → feels great
- Day 3 – Requirement changes → regenerate → everything is gone
Consequences
- Lost developer time
- Fear of touching generators
- Divergent specs & code
- Architecture decay
You don’t just lose code — you lose trust.
ASA’s deterministic pipeline
Slices
Self‑contained vertical feature units, e.g.:
domains/auth/login/
├── slice.spec.md
├── slice.contract.json
├── handler.py
├── service.py
├── repository.py
├── schemas.py
└── tests/
Specs (Human‑readable)
Each slice includes a spec with seven required sections:
- Purpose
- Inputs
- Outputs
- Behaviour
- Errors
- Side Effects
- Dependencies
Contracts (Machine‑readable)
A JSON schema is generated from the spec, for example:
{
"inputs": { "email": "string", "password": "string" },
"outputs": { "jwt_token": "string", "expires_in": "int" }
}
Deterministic templates and marker‑based preservation
ASA’s templates contain no randomness. Instead of guessing “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 ===
During regeneration ASA:
- Extracts everything inside the markers
- Regenerates the surrounding structure
- Inserts your code back exactly where it belongs
This 100 % deterministic round‑trip guarantees that your code can never be overwritten by accident.
Safe regeneration example
You have a working login slice. Later, security wants to log ip_address.
- Update
slice.spec.md:
- email: string
- password: string
- ip_address: string # new
- Run the regeneration commands:
asa generate-contract auth/login
asa regenerate-slice auth/login
ASA updates:
- Models
- Handler signature
- Tests
- Contract
Your custom logic remains intact.
Why determinism matters for AI‑assisted development
- Multiple agents may touch the same slice
- Specs can change daily
- Contracts evolve quickly
- Automated workflows need predictable behavior
- CI pipelines must 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 architecture is built for the AI era.
ASA Core v1.0: Ideal scenarios
- 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 lets you embrace regeneration instead of fearing it. Regeneration should not feel like:
rm -rf my_code
It should feel like safely updating the structure while preserving your logic.
Key ingredients of ASA Core v1.0
- 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: