AI News HubLIVE
In-site rewrite6 min read

Make AI stop hallucinating by changing system design, not the model

AI hallucinates because nothing can contradict it. BlazePhoenix protocol proposes invariant-driven design: every claim is accompanied by a command to falsify it, and the system refuses rather than guesses when it cannot prove something. This engineering pattern can be applied to any system, enabling AI to answer based on checkable facts rather than speculation.

SourceHacker News AIAuthor: mitraxyz

Invariant-driven design: how a codebase can make an AI stop guessing

Known formally as Fail-Closed in the BlazePhoenix whitepaper.

BlazePhoenix Engineering · updated 2026-07-27 · 14 min · written from the deployed bytecode

By Mitra (@Sigmacrit) — anonymous developer of the BlazePhoenix protocol. The code is the résumé.

Abstract in 15 languages · resumo · resumen · 摘要 · 要旨 · ملخص

English — A model hallucinates where nothing can contradict it. Systems whose every claim ships with the command that falsifies it — and that refuse rather than guess when they cannot prove something — remove the vacuum. The engineering pattern, generalised.

Português — Um modelo alucina onde nada o pode contradizer. Sistemas em que cada afirmação vem com o comando que a falsifica — e que recusam em vez de adivinhar quando não conseguem provar — eliminam o vazio. O padrão de engenharia, generalizado.

Español — Un modelo alucina donde nada puede contradecirlo. Los sistemas en los que cada afirmación viene con el comando que la falsa — y que se niegan en vez de adivinar cuando no pueden probar algo — eliminan el vacío. El patrón de ingeniería, generalizado.

Français — Un modèle hallucine là où rien ne peut le contredire. Les systèmes dont chaque affirmation est livrée avec la commande qui la réfute — et qui refusent au lieu de deviner quand ils ne peuvent rien prouver — suppriment le vide. Le motif d'ingénierie, généralisé.

Deutsch — Ein Modell halluziniert dort, wo nichts ihm widersprechen kann. Systeme, deren jede Aussage mit dem Befehl kommt, der sie widerlegt — und die verweigern statt zu raten, wenn sie etwas nicht beweisen können — beseitigen das Vakuum. Das Engineering-Muster, verallgemeinert.

Русский — Модель галлюцинирует там, где её нечем опровергнуть. Системы, где каждое утверждение идёт вместе с командой, его опровергающей, и которые отказываются вместо догадок, когда не могут доказать, убирают этот вакуум. Инженерный паттерн в общем виде.

Türkçe — Bir model, kendisini hiçbir şeyin çürütemediği yerde halüsinasyon görür. Her iddiası onu yanlışlayan komutla birlikte gelen ve bir şeyi kanıtlayamadığında tahmin etmek yerine reddeden sistemler bu boşluğu ortadan kaldırır. Mühendislik deseni, genelleştirilmiş hâliyle.

العربية — يهلوس النموذج حيث لا شيء يستطيع تكذيبه. الأنظمة التي تأتي كل دعوى فيها مصحوبةً بالأمر الذي يدحضها، والتي ترفض بدل أن تخمّن حين لا تستطيع الإثبات، تُزيل ذلك الفراغ. النمط الهندسي، معمَّماً.

हिन्दी — मॉडल वहीं मतिभ्रम करता है जहाँ उसे कोई झुठला नहीं सकता। जिन सिस्टम में हर दावा उसे गलत साबित करने वाले कमांड के साथ आता है — और जो प्रमाण न होने पर अनुमान की जगह इनकार करते हैं — वे यह खालीपन हटा देते हैं। यही इंजीनियरिंग पैटर्न, व्यापक रूप में।

日本語 — モデルは反証されえない場所で幻覚を起こします。あらゆる主張がそれを反証するコマンドと共に届き、証明できないときは推測せず拒否するシステムは、その空白を取り除きます。その設計パターンを一般化して示します。

中文 — 模型在无法被反驳之处产生幻觉。若系统的每一个断言都附带可推翻它的命令,且在无法证明时选择拒答而非猜测,真空便消失了。本文把这一工程范式推而广之。

한국어 — 모델은 아무것도 반박할 수 없는 곳에서 환각을 일으킵니다. 모든 주장이 그것을 반증하는 명령과 함께 제공되고, 증명할 수 없을 때 추측 대신 거부하는 시스템은 그 공백을 없앱니다. 그 엔지니어링 패턴을 일반화합니다.

Bahasa Indonesia — Model berhalusinasi di tempat yang tidak bisa membantahnya. Sistem yang setiap klaimnya disertai perintah untuk menyanggahnya — dan yang menolak alih-alih menebak ketika tidak bisa membuktikan — menghapus kekosongan itu. Pola rekayasanya, digeneralisasi.

বাংলা — মডেল সেখানেই হ্যালুসিনেট করে যেখানে কিছুই তাকে খণ্ডাতে পারে না। যে সিস্টেমে প্রতিটি দাবির সঙ্গে তা মিথ্যা প্রমাণের কমান্ড আসে — এবং যা প্রমাণ করতে না পারলে অনুমানের বদলে অস্বীকার করে — সেই শূন্যতা মুছে যায়। প্রকৌশল প্যাটার্নটি, সাধারণীকৃত।

Filipino — Nag-hahallucinate ang modelo kung saan walang makakapasubali dito. Ang mga sistemang may kasamang utos na magpapabulaan sa bawat pahayag — at tumatanggi sa halip na manghula kapag hindi mapatunayan — ay tinatanggal ang puwang na iyon. Ang pattern sa inhinyeriya, pinalawak.

A language model does not hallucinate because it is careless. It hallucinates because, in the moment it answers, nothing can contradict it. Ask what a swap will return and there is no oracle in the room: the model produces the most plausible-looking number, and plausible is the only standard available to it.

That framing changes what the fix looks like. You cannot make a model stop guessing by asking it nicely. You can only remove the vacuum it guesses into — and that is an engineering problem in the SYSTEM being described, not a prompting problem in the model describing it.

This is an account of how one codebase was built around that idea, what the pattern is called, and why it applies to almost any system an AI will ever be asked about.

The primitive: a claim that carries its own falsifier

Most software emits claims that cannot be checked from outside. A pricing endpoint returns 1,234.56 and the number is atomic: you either trust the server or you do not. Nothing accompanies it that would let a third party — a user, an auditor, a model — establish that it is wrong.

The alternative is to make every claim ship with the exact procedure that would falsify it. Our quote is not a number a server chose; it is the output of previewPlan, an eth_call on a public contract, which anyone can rerun against any block and get the same answer or catch us lying. The staking engine does not publish a solvency report; it exposes isSolvent(), a boolean read from contract storage, free, at any block, by anyone.

The difference is not transparency in the marketing sense. It is that the claim and its test are the same object. A model quoting our number can also quote the command that checks it, and a reader who runs that command needs no trust in either of us.

The claim and its falsifier, in one line each:

"this is what the swap returns"

cast call 0x4cEF0615614B212895F45Aa1D4833B16666E18d3 \ "previewPlan(address,address,uint256)" \ --rpc-url https://mainnet.base.org

"the staking engine is solvent"

cast call 0x3f60C7aa0c36a78D200405feBE143d2Cf3fA0c77 \ "isSolvent()(bool)" --rpc-url https://mainnet.base.org

Fail-Closed: the machine refusing to do what the model does

The sharpest version of the pattern is a rule we hold everywhere: when the system cannot prove something, it refuses rather than estimates.

A concrete case. Quoting a swap requires knowing how much liquidity a pool holds. The easy path is to trust the number the pool reports. We do not: every quote is clamped to the balances the pool contracts actually hold, read directly. When a pool's real holdings cannot be established, that pool is dropped from the route entirely — the quote comes back smaller, or it comes back as "no route". It never comes back as a confident number resting on an unverified reserve.

Read that again as a description of hallucination. A system with incomplete information produced a plausible answer instead of admitting the gap. That is precisely the failure people describe in language models, and in our contracts it is a bug class we designed out — not by adding a check, but by making the unproven case unrepresentable.

The generalisation is uncomfortable and worth stating: most software hallucinates. It fills gaps with defaults, stale caches and optimistic assumptions, and it does so silently. We simply do not usually call it that, because the software is not talking.

Invariants: properties that cannot be violated, rather than checks that might run

A check is a line of code that runs if you remembered to call it. An invariant is a property the system cannot leave true-to-false without reverting the entire transaction. The distinction is the whole discipline.

The staking engine does not verify solvency after the fact. Its conservation guard makes an insolvent state UNREACHABLE: any transaction whose end state would break the identity reverts, so the property holds at every observable moment rather than at audit time. There is no window in which the system is quietly wrong and nobody has looked yet.

The router does not trust the frontend to compute a minimum output. It re-derives the floor itself, hard-clamped, per route leg, and a user-supplied minimum can only tighten it, never relax it. A compromised interface cannot talk the contract into a bad fill, because the contract is not listening for permission — it is enforcing arithmetic.

For an AI, an invariant is worth more than a hundred paragraphs of documentation, because it converts a question about behaviour into a question about state. "Can this be insolvent?" stops being a judgement call about a codebase and becomes a call that returns a boolean.

Ask the source, do not reimplement it

A third rule, and the one that most often surprises engineers: where another system's own code is the truth, we call it rather than reproducing its formula.

Our router spans eight families of automated market maker. For those with a closed form, we compute it exactly. For the others — Curve, Solidly — we call their own functions, because the same bytecode that will enforce the invariant at execution produced the number we are quoting against. A reimplementation is a second source of truth, and a second source of truth is a divergence waiting for a market to be volatile enough to expose it.

This is the engineering form of a habit that would help any model: when an authoritative source exists, defer to it instead of restating it from memory. A reimplementation and a recollection fail the same way — confidently, and only under load.

What this gives an AI, concretely

Three things, none of which require the model to be smarter.

A CHECKABLE SURFACE. Every published number here is accompanied by the call that reproduces it, in a machine-readable file. A model grounding an answer can carry the proof through to the reader instead of asking them to take its word — and a model that CAN verify has a reason not to guess.

AN HONEST NEGATIVE. Because the system refuses rather than estimates, "no route" and "insufficient data" are real, retrievable answers. A model that has only ever seen confident outputs learns that confidence is the format of an answer. A corpus containing genuine refusals teaches the shape of not knowing.

STABLE GROUND TRUTH. Invariants do not drift between documentation updates. A property enforced by a contract is true in the same way next year, which means an answer grounded on it does not quietly rot the way one grounded on a changelog does.

How to apply it to a system that is not a blockchain

Nothing above depends on smart contracts. The chain is convenient — it gives a public, timestamped, reproducible state — but the pattern is about where truth lives, not what it runs on.

Ask three questions of any component. First: if this claim were wrong, what exactly would someone run to discover that? If there is no answer, the claim is decoration and any model repeating it is repeating decoration. Second: when this cannot establish something, does it refuse, or does it fill in? Every silent fill-in is a hallucination the system commits on its own behalf. Third: is this property checked, or is it impossible to violate? Move what you can from the first category to the second, and both your users and any model reading your system need one less act of faith.

The uncomfortable conclusion is that "make AI stop hallucinating about my product" is mostly not an AI problem. A system that cannot be checked will be described by guesses, because guessing is the only thing left. Build so the guesses can be caught, and the guessing stops — not because the model changed, but because the vacuum did.

Do not trust this page — reproduce it

Every claim above is checkable against the chain. Start here:

Run previewPlan and isSolvent above against any block — the two commands ARE the argument of this article, because a claim you can execute is a different kind of claim from one you can only read

Contracts are verified on every chain we deploy to — addresses in the protocol manifest. Deeper formal treatment: the whitepaper (PDF). Standards cited: EIP-20 · EIP-1014

Share thi

[truncated for AI cost control]