Deterministic harness for LLM code edits — the AI proposes, the gate decides
TypeScript
0
33 commits
updated Oct 1, 2026
The AI thinks, the gate decides.
A deterministic harness for LLM code edits. The model proposes SEARCH/REPLACE blocks; a local runtime applies them in a shadow git worktree, checks the result with tsc --noEmit, and merges only if compilation passes. The LLM never writes to your real branch.
📄 Read the full story: The AI thinks, the gate decides — how I made LLM code edits deterministic (42× fewer tokens) 🇪🇸 README en español
Agentic coding loops pay their token bill twice: every turn re-sends the whole trajectory (files, tool results, reasoning) to the model, and "thinking" modes multiply both the tokens per turn and the number of turns. D-Engine removes the loop for the bounded-edit case: one prompt, one patch set, one deterministic gate.
Same task, same model (V4.1-Flash), same literal prompt:
| Runtime | Tokens | Time |
|---|---|---|
| D-Engine v0.2.2 | 2,552 | ~4 s |
| dsh Minimal (single shell tool) | 34,600 | 1m04s |
| dsh, effort off | 37,100 | 6 s |
| dsh factory defaults (thinking High) | 107,000 | 28 s |
The toolbox is not the cost — the agentic loop is.
SEARCH/REPLACE blocks — nothing else.tsc --noEmit is the only source of truth.10 frozen tasks, same model family, one attempt each, full methodology disclosed:
| Metric | D-Engine | Agentic loop (dsh, factory) |
|---|---|---|
| Quality (max 50) | 48 | 48 |
| Avg tokens per task | ~2,100 (bounded) | ~93,000 (range 32K–214K) |
| Avg time per task | ~2.7 s | ~38 s |
| Broken commits on main | 0 | 1 (Aider, trap task) |
Tied quality, 14–42× fewer tokens, a predictable bill, zero broken merges. The full benchmark — frozen prompts, voided rows, hallucination incident and all — ships in docs/benchmark.en.md (español).
Requirements: Node.js, git, TypeScript in the target repo (tsc --noEmit).
git clone https://github.com/corruchaga/D-Engine
cd D-Engine
npm install
cp .env.example .env
Fill in LLM_BASE_URL, LLM_API_KEY and LLM_MODEL in .env.
Development (no build):
npm run dev
Local production:
npm run build
npm start
The TUI asks for: change description, target file (empty Enter = automatic selector), safety mode (Fast / Verify / Shadow) and confirmation. Fast merges after applying; Verify adds a semantic audit; Shadow never merges without permission.
npm run typecheck is equivalent to tsc --noEmit.
License: MIT
TypeScript
100.0%
Deterministic harness for LLM code edits — the AI proposes, the gate decides
TypeScript
0
33 commits
updated Oct 1, 2026
The AI thinks, the gate decides.
A deterministic harness for LLM code edits. The model proposes SEARCH/REPLACE blocks; a local runtime applies them in a shadow git worktree, checks the result with tsc --noEmit, and merges only if compilation passes. The LLM never writes to your real branch.
📄 Read the full story: The AI thinks, the gate decides — how I made LLM code edits deterministic (42× fewer tokens) 🇪🇸 README en español
Agentic coding loops pay their token bill twice: every turn re-sends the whole trajectory (files, tool results, reasoning) to the model, and "thinking" modes multiply both the tokens per turn and the number of turns. D-Engine removes the loop for the bounded-edit case: one prompt, one patch set, one deterministic gate.
Same task, same model (V4.1-Flash), same literal prompt:
| Runtime | Tokens | Time |
|---|---|---|
| D-Engine v0.2.2 | 2,552 | ~4 s |
| dsh Minimal (single shell tool) | 34,600 | 1m04s |
| dsh, effort off | 37,100 | 6 s |
| dsh factory defaults (thinking High) | 107,000 | 28 s |
The toolbox is not the cost — the agentic loop is.
SEARCH/REPLACE blocks — nothing else.tsc --noEmit is the only source of truth.10 frozen tasks, same model family, one attempt each, full methodology disclosed:
| Metric | D-Engine | Agentic loop (dsh, factory) |
|---|---|---|
| Quality (max 50) | 48 | 48 |
| Avg tokens per task | ~2,100 (bounded) | ~93,000 (range 32K–214K) |
| Avg time per task | ~2.7 s | ~38 s |
| Broken commits on main | 0 | 1 (Aider, trap task) |
Tied quality, 14–42× fewer tokens, a predictable bill, zero broken merges. The full benchmark — frozen prompts, voided rows, hallucination incident and all — ships in docs/benchmark.en.md (español).
Requirements: Node.js, git, TypeScript in the target repo (tsc --noEmit).
git clone https://github.com/corruchaga/D-Engine
cd D-Engine
npm install
cp .env.example .env
Fill in LLM_BASE_URL, LLM_API_KEY and LLM_MODEL in .env.
Development (no build):
npm run dev
Local production:
npm run build
npm start
The TUI asks for: change description, target file (empty Enter = automatic selector), safety mode (Fast / Verify / Shadow) and confirmation. Fast merges after applying; Verify adds a semantic audit; Shadow never merges without permission.
npm run typecheck is equivalent to tsc --noEmit.
License: MIT
TypeScript
100.0%