MaxSvargal

MaxSvargal

Foundry - The Anti-Entropy Development Environment for Platforms and AI-Driven Engineering

For the past two years, I’ve been obsessed with a technical problem: **How do we effectively use LLMs to engineer, manage, and scale complex distributed systems without them collapsing into unmaintainable, hallucinated legacy code?**

If you’ve used AI coding assistants, you know the reality. They act like eager junior developers. You ask for a feature, and they start inventing new ways to mix concrete. They hallucinate, ignore your project’s architectural constraints, leads to fragile abstractions, and silently introduce massive technical debt.

To solve this, I realized we needed to fundamentally change the surface area the AI interacts with. I needed a declarative language where structure imparts determinism, because LLMs are designed for structured data and understand intent far better when following a constrained, predictable path.

This realization sparked a two-year research and engineering journey that spanned multiple languages, architectures, and paradigms. Today, I am thrilled to open-source the culmination of that journey: **Foundry**.

### The Two-Year Journey: From Rust to Go to Elixir

**Generation 1: The Rust Era (ArchitectLM/cascade)**

I started by building a high-performance, edge-compatible declarative workflow engine in Rust. It used a YAML DSL, WASM-based plugins for isolation, and Content-Addressed Storage (CAS) for immutable deployments. It was incredibly fast and safe. However, as the need for dynamic business rules grew, I hit a wall. Extending it required high entry threshold, complex integrations, and the boilerplate of maintaining a custom DSL became a bottleneck.

**Generation 2: The Go Era (Cascade Platform)**

To reduce code complexity, I pivoted to an “Application-as-Data” paradigm in Go. The idea was to stop reinvent backend entirely. The platform integrated heavy enterprise tools: Temporal for stateful workflows, SpiceDB for ReBAC authorization, and Flowable for business rules. While the architecture was incredibly powerful, the infrastructural complexity was overwhelming. Managing distributed caches, sagas, backpressure, and state machines across multiple external services is an ambitious task that takes years to perfect.

**The Epiphany: Elixir and the Ash Framework**

I needed something highly integrated, high-level, scalable and declarative out of the box. I needed a mature compiler, proper AST manipulation, and meta-programming to reduce complexity.

After testing LLM efficiency across various languages, **Elixir emerged as the clear winner.**

Elixir’s predictable structure, immutability, and OTP foundation natively solved the distributed system problems I was trying to wire together in Go. But the real magic was the **Ash Framework**. It shrinks the codebase drastically, requiring significantly fewer tokens to write and maintain, which is the holy grail for LLM context windows. It scales automatically, eliminating the need to manually orchestrate low-level abstractions.

### Enter Foundry: The Operating System for Complex Domains

**Foundry** is a governed development environment for complex domain platforms built on Elixir and Ash.

With Foundry, the paradigm shifts entirely. The AI doesn’t mix concrete anymore. It simply follow a gold standard, reaches into the Foundry library, pulls out a pre-cast, mathematically proven abstraction (like `ash_idempotency`, `ash_reactor` or `ash_state_machine`), and bolts it together. It also add some annotations to link with business intend that specification holds.

Foundry’s core philosophy is simple: **Your codebase is the spec, the spec is always true, and the copilot never loses context.**

#### 1. An Anti-Entropy System

The real competition in software engineering isn’t other tools; it’s the natural entropy of complex systems. Documentation drifts from code. Intent diverges from implementation.

Foundry fights entropy at every level:

- **The Spec-Kit** encodes business intent.

- **The Linter** makes that intent executable.

- **The System Map** makes architectural drift visible instantly.

- **Tests are displayed on the System Map** provides easier review.

- **The Copilot** operates strictly within these encoded constraints.

#### 2. AI That Understands Your Architecture

Unlike generic AI assistants that rely on file context and hallucinate dependencies and implicit relationships, Foundry’s Copilot uses structured retrieval over live DSL introspection and knows the entire compact map of the system. It knows your current stack and dependency versions, your project’s invariants, and your compliance obligations, it has references to a gold standard like `ash_hq` and `foundry_hq` before it generates a single line of code. Using AST-safe generation (via Igniter), it doesn’t just guess text, it safely modifies your system’s syntax tree in a safe way.

#### 3. Two Speeds: From Startup to Regulated Enterprise

Foundry adapts to your risk tolerance:

- **Execution-Led:** Minimal ceremony. Fast iteration. Auto-applied structural changes. The Copilot generates executable BDD scenarios directly from your PR descriptions. Reversibility is a first-class primitive, allowing you to semantically undo complex domain changes instantly.

- **Enterprise:** Full governance. Changes require proposals, ADRs (Architecture Decision Records), and compliance-linked flags. Scenarios and property tests are generated directly from regulatory and business requirements.

#### 4. The Living System Map

In traditional systems, architecture diagrams (C4, ERDs) are out of date the minute you commit code. Foundry generates a live, interactive System Map generated directly from the compiler’s metadata (using `spark_meta`). It extracts the resources, relationships, state machines, links, state machine lifecycles, authorization matrices and compliance tags, and renders an interactive graph. It has an “Engineer View” for the technical team and a “Domain View” for the business experts. If a developer removes a compliance tag, the map updates instantly. Drift is technically impossible because it is generated directly from the compiler.

It also provides a visual representation of code changes as well as full test tracing directly on the system map.

### Who is Foundry For?

Foundry is built for domains where rules matter enormously, where changing one rule cascades through the system, and where audit trails are mandatory.

If you are building platforms in **Healthcare, FinTech, Insurance, Legal Tech, Logistics, or EdTech**, Foundry provides the governance and architectural safety you need, without sacrificing development velocity.

### Why This Matters

Every engineering team maintaining a complex platform experiences the same pain: the original architect leaves, a new engineer adds a delete action, the compliance test is skipped, and six months later, you have a critical incident.

Foundry prevents this. It encodes institutional knowledge as executable constraints. The linter catches violations at the moment of introduction. The proposal model makes architectural changes visible. The Copilot operates strictly within these encoded constraints.

**Stop fighting entropy. Let your code be the spec.**

### Explore the Open-Source Ecosystem

Foundry is fully open-source and modular. Explore the repositories that was created for Foundry to build the future of AI-driven, spec-first engineering:

- **[Foundry Homepage](https://foundry.definitivespec.org/)** Learn and download a desktop application (Linux and macOS).

- **[Foundry Studio Demo](https://studio.cloud.foundry.definitivespec.org/)** Try a real project online.

- **[Foundry Library]( GitHub - FoundryStack/foundry: Foundry is the governed development environment for complex domain platforms. · GitHub ):** The core governed development environment.

- **[Foundry Studio]( GitHub - FoundryStack/foundry-studio · GitHub ):** The visual interface and living System Map.

- **[Spark Lint]( GitHub - FoundryStack/spark_lint: Lint rule runner for Elixir/Spark/Ash projects · GitHub ) & [Spark Meta]( GitHub - FoundryStack/spark_meta: Spark DSL walker and introspection library · GitHub ):** AST-aware linting and metadata extraction.

- **[Scenario Tracer]( GitHub - FoundryStack/scenario_tracer: ScenarioTracer wires together AST scanning, runtime trace collection, and report generation into a single Mix task abstraction · GitHub ) & [Ex Tracer]( GitHub - FoundryStack/ex_tracer: Scenario extraction primitives for Elixir test suites · GitHub ):** Executable specifications and deep observability.

- **[Phoenix LLM Chat]( GitHub - FoundryStack/phoenix_llm_chat: An extensible Phoenix LiveView chat component with streaming LLM support and session management · GitHub ):** The context-aware AI copilot interface.

- **[AshSDUI]( GitHub - FoundryStack/ash_sdui: Server-Driven UI for Phoenix LiveView applications backed by Ash resources · GitHub ):** Server-Driven UI for Phoenix LiveView applications backed by Ash resources.

- **[Demo Application]( GitHub - MaxSvargal/foundry-igaming: igaming fintech solution based on foundry · GitHub ):** Fintech solution based on foundry.

- **[Cascade on Rust]( GitHub - ArchitectLM/cascade: Sophisticated data-driven workflow orchestration · GitHub ):** Sophisticated data-driven workflow orchestration.

- **[Cascade on Golang]( GitHub - MaxSvargal/cascade-platform-go: Full-stack "Application-as-Data", "AI-first" development platform · GitHub ):** Full-stack “Application-as-Data” development platform.

- **[DefinitiveSpec](https://definitivespec.org/):** Definitive Development Methodology for Specification-Driven Development.

Check out the code, read the docs, and let me know what you think! I am looking for partners to evolve the project.

Join us on Discord DefinitiveSpec Community @maxsvargal

_P.S. The project is in the preview stage and is not ready for production yet, but I hope that we will bring it to perfection through iterative attempts at implementing real projects._

Most Liked

jam

jam

Fwiw, I’d leave it as is. I think it’s cool and pretty unique.

Dmk

Dmk

Interesting idea. Will have to check it out when I have a bit of time.

The website hero is sweet though!

jam

jam

This sounds interesting. Would be great if you can make it work with Hologram.

Where Next?

Popular in Announcing Top

OvermindDL1
I created a new library (rather I pulled out a couple files from my big project), it manages an operating system PID file for the BEAM. ...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 43487 311
New
pkrawat1
Presenting Aviacommerce, open source e-commerce platform in Elixir Aviacommerce is an open source e-commerce platform in Elixir. We at...
New
mbuhot
Leverage Open Api 3.0 (Swagger) to document, test, validate and explore your Plug and Phoenix APIs. Generate and serve a JSON Open API ...
New
Azolo
Hey everyone, I just released WebSockex which is a Elixir WebSocket client. WebSockex strives to work as a OTP special process, be RFC6...
New
Jskalc
Hi! Today, after a couple weeks of development I’ve released v0.1 of LiveVue. It’s a seamless integration of Vue and Phoenix LiveView, i...
New
hpopp
After just over two years in development, this latest version of Pigeon is what I finally consider done in regards to my original vision ...
New
achempion
Hi, I would like to tell about my initiative to further maintain and develop Waffle project which is the fork of Arc library. The progre...
New
michalmuskala
Hello everybody. I have just released Jason - a new JSON library. You might be wondering, why do we need a new library? The primary foc...
New
kevinlang
Hey all, We have made an Ecto3 Adapter for SQLite3, ecto_sqlite3! We have successfully on-boarded the full suite of integration tests (...
New

Other popular topics Top

axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 48342 226
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31013 112
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54120 245
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New

We're in Beta

About us Mission Statement