Epi — Epistemic Programming Interface. A zero-stack intent-oriented language with an epistemic type system that formally separates deterministic and AI-inferred computation.
Project description
Epi — Epistemic Programming Interface
A Zero-Stack Intent-Oriented Language with an Epistemic Type System
Research Status: Active / Structural Validation (v0.3)
Author: Randerson Rebouças — PhD Candidate, UFRGS
The Problem
Modern full-stack development is a stack of accidental complexity. To build a simple application that stores data and classifies it with AI, a developer must:
- Define a database schema (Prisma/SQL)
- Write API routes (Express/FastAPI)
- Add authentication middleware
- Create validation schemas (Zod/Pydantic)
- Wire LLM inference calls with error handling
- Build UI components (React/Next.js)
- Connect everything with state management
Seven layers. Three to five languages. Dozens of files. And the actual business logic — "store a contract and classify its risk" — fits in a single sentence.
Worse: when AI enters the picture, traditional type systems cannot distinguish between a value that was computed (a UUID) and a value that was hallucinated (an AI classification). A string is a string. The database doesn't know. The compiler doesn't care. The hallucination becomes ground truth.
The Solution
Epi is a language with five primitives and an Epistemic Type System that formally separates what is known (deterministic) from what must be inferred (stochastic) — in the same grammar, in the same file.
You write .epi. The transpiler generates a complete, auditable project: database schema, API routes, auth middleware, validation schemas, LLM inference functions, and UI components.
One file in. Full stack out. Every AI output validated.
How It Looks
@Language: Epi v0.2
@Goal: "Contract Analysis with Human-in-the-loop"
Entity Contrato {
id: UUID(auto),
titulo: Text,
documento: Text,
valor: Decimal,
criado_em: DateTime(auto),
risco: AI.Enum(Alto, Medio, Baixo, strict: true)
}
// ▲ Rigid types: deterministic ▲ Epistemic type: AI-inferred, validated
Guard SomenteAdvogados {
Condition: Auth.Role == "Lawyer"
}
Pulse ExtrairRisco {
Input: Contrato
Protect: Guard.SomenteAdvogados
Process:
Execute: AI.scan(
source: Input.documento,
prompt: file("@prompts/legal_scan.md"),
temperature: 0.1,
on_fail: Fallback.ManualReview(Queue: "Advogados")
)
Output: Contrato.risco
}
Pipeline AnalisarContrato {
Flow: ExtrairRisco -> GerarResumo -> Notificar
On_Error: Retry(max: 3, backoff: exponential)
}
Lens Dashboard {
Mood: "Clean, Legal-Tech"
Display:
Table(Contrato, columns: [titulo, valor, risco]),
Form(Contrato) -> Button("Analisar").trigger(ExtrairRisco)
}
50 lines. No framework boilerplate. No hand-written middleware. No untyped AI calls. The transpiler generates everything — and the Epistemic Type System guarantees that risco is validated against ["Alto", "Medio", "Baixo"] before it ever touches the database.
The Five Primitives
| Primitive | What it does | Epistemic role |
|---|---|---|
| Entity | Data schema with typed fields | Declares the epistemic boundary — rigid fields vs. AI-inferred fields |
| Guard | Auth & authorization constraints | Deterministic — transpiles to middleware |
| Pulse | AI execution with hallucination control | Epistemic — every AI.* call has temperature, prompt, and on_fail |
| Pipeline | Composes Pulses into flows | Deterministic — orchestration with error strategy |
| Lens | Semantic UI declaration | Mixed — structure is deterministic, Mood is epistemic |
The Epistemic Type System
The core innovation. Every type in Epi belongs to one of two domains:
Rigid Types — deterministic, no AI involvement:
UUID(auto) Text Int Float Decimal Bool DateTime(auto) JSON
Epistemic Types — AI-inferred, runtime-validated:
AI.Enum(Value1, Value2, strict: true)
AI.Text(max_tokens: N)
AI.Classification(labels: [...])
AI.Score(min: 0, max: 1)
AI.Embedding(dimensions: N)
A single AI.Enum(Alto, Medio, Baixo, strict: true) declaration generates:
- A database column (
Stringin Prisma) - A runtime validation schema (Zod enum / Pydantic validator)
- An LLM inference call with temperature and fallback constraints
If it compiles, it validates.
Architecture
Three-layer transpiler. The LLM is formally excluded from Layers 1 and 2.
.epi source → [Layer 1: Parser] → [Layer 2: Rigid Generator] → [Layer 3: Epistemic Generator]
Lark + EBNF Jinja2 templates LLM (constrained)
100% deterministic 100% deterministic validated by Layer 2
See ARCHITECTURE.md for the full technical breakdown.
Quick Start
# Clone
git clone https://github.com/RandMelville/epi-lang.git
cd epi-lang
# Install
pip install -e ".[dev]"
# Validate syntax
epi validate examples/contrato.epi
# Transpile to a full project
epi transpile examples/contrato.epi --target nextjs --outdir ./generated
Project Structure
grammar/epi.lark EBNF grammar definition
epi/parser/ast_nodes.py Pydantic AST models (Epistemic Type System)
epi/parser/builder.py Lark Transformer (parse tree → typed AST)
epi/generators/ Code generators
deterministic/ Layer 2: Prisma, middleware, routes
epistemic/ Layer 3: AI inference stubs, Lens UI
epi/cli.py Typer CLI (parse, validate, transpile)
examples/contrato.epi Canonical example
SPEC.md Formal language specification
ARCHITECTURE.md Technical architecture
MANIFESTO.md Project philosophy
Documentation
| Document | Purpose |
|---|---|
| SPEC.md | Formal language specification — grammar, type system, primitives |
| ARCHITECTURE.md | Transpiler architecture — three layers, design decisions |
| MANIFESTO.md | Philosophy — why epistemic types matter |
| CONTRIBUTING.md | How to contribute |
Status
v0.2 — Research / Structural Validation
- Formal specification (SPEC.md)
- EBNF grammar (Lark)
- AST node models (Pydantic)
- Lark Transformer (parser → typed AST)
- Deterministic generators (Prisma, middleware, routes with retry)
- Epistemic generators (stubs with fallback metadata)
- CLI (parse, validate, transpile)
- Parser end-to-end validation
- Template expansion for FastAPI target
- Epistemic layer integration (Claude API)
- Lens Mood → LLM-driven styling
- Academic paper (ArXiv preprint)
Related Work
| System | Relationship to Epi |
|---|---|
| ProbZelus (PLDI 2020) | Separates deterministic/probabilistic in reactive streams — Epi adapts this to full-stack transpilation |
| SlicStan (POPL 2019) | Information-flow types for probabilistic programs — Epi generalizes to application-level types |
| BAML | Typed LLM function signatures — Epi extends to full application generation |
| Wasp | Full-stack DSL (React + Node) — Epi adds epistemic types and AI-aware transpilation |
Citation
If you use Epi in academic work, please cite:
@software{reboucas2026epi,
author = {Rebouças, Randerson},
title = {Epi: An Epistemic Programming Interface for AI-Aware Full-Stack Transpilation},
year = {2026},
url = {https://github.com/RandMelville/epi-lang},
version = {0.2.0}
}
Contributing
See CONTRIBUTING.md for guidelines.
License
Apache License 2.0 — Copyright (c) 2026 Randerson Rebouças
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file epi_lang-0.3.0.tar.gz.
File metadata
- Download URL: epi_lang-0.3.0.tar.gz
- Upload date:
- Size: 82.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2efad20a6e777bd873f74b2f6bcdace756f46e64d4729b2e32c150863e50882
|
|
| MD5 |
8104cc70e372b40843027e72e3454dec
|
|
| BLAKE2b-256 |
a60a4e09e5e5a8f1118071ce63d3b830af9d6ee35289a33539a3c74e598ee33d
|
File details
Details for the file epi_lang-0.3.0-py3-none-any.whl.
File metadata
- Download URL: epi_lang-0.3.0-py3-none-any.whl
- Upload date:
- Size: 45.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
348e9b78ea33f92c3d0fb35dd6f0305b8ae1977596b3c702ce131edc5b8a0af5
|
|
| MD5 |
75bb1db56d51f2f9bbadb7bf5113136b
|
|
| BLAKE2b-256 |
e09c7344f3c653bdaa736ae145b3b871368fb75f397367d8b9ceb72e45848a7f
|