Stop AI from suggesting workarounds before it proves the rejection
Most AI coding assistants follow the same workflow:
Read the compiler error
Explain it
Suggest a fix
This works well in many languages.
In Rust, it often breaks the language’s guarantees.
The problem is not incorrect explanations
Rust compiler errors — especially borrow checker rejections — are not hints.
They are formal rejections:
the requested state cannot be proven safe
or cannot exist under Rust’s invariants
Yet AI assistants usually treat them as:
“Something the user probably wants to work around.”
This leads to a predictable pattern:
clone() appears too early
Arc becomes the default escape hatch
RefCell and unsafe show up without an explicit tradeoff
The AI does not decide which invariant is being sacrificed — it just sacrifices one.
The core idea: suggestion must be earned
Instead of making AI “better at explaining Rust”, this project enforces one rule:
An AI assistant must not suggest anything until it proves it is allowed to.
This is implemented as a fail-closed adjudication gate.
Two roles, one hard boundary
The system splits responsibility:
- Adjudicator (LLM)
The LLM is allowed to:
classify the rejection (A / B / C / D)
describe conflicts or proof gaps
state which Rust invariant is preserved
It is not allowed to:
suggest code
propose workarounds
hint at escape mechanisms
- Auditor (Gate)
The auditor:
does not interpret meaning
does not understand Rust semantics
performs only structural validation
It checks:
required fields exist
enums match
scopes are consistent
forbidden suggestion behavior is absent
If validation fails → fail-close.
Fail-close is the key design choice
Most AI systems fail open:
“If unsure, still help.”
Compilers fail closed:
“If unproven, stop.”
This gate copies the compiler’s philosophy, not the assistant’s instinct.
When adjudication is incomplete:
no suggestions
no workaround hints
no “you could try…”
Only a structured rejection remains.
Minimal flow
Input (code + intent)
↓
Adjudicator (LLM)
- classify rejection
- describe conflict ↓ Auditor (Gate)
- schema validation
- enum checks ↓ PASS → suggestions allowed FAIL → suggestions blocked
The gate decides — not the model.
What this demo intentionally does NOT do
This project does not:
map rustc error codes
judge explanation quality
optimize prompts
teach Rust
It proves only one thing:
Suggestion control can be enforced as a product behavior, not a prompt convention.
Why Rust makes this visible
Rust exposes invariant violations explicitly.
But the same failure mode exists in:
security tooling
financial systems
safety-critical code
policy-driven systems
Any domain where “helpfulness” can override authority needs a gate like this.
Takeaway
AI assistants should not compete with compilers.
They should respect them.
Sometimes the correct output is not a workaround —
but silence enforced by rules.
Repo (single-file demo, intentionally minimal):
https://github.com/yuer-dsl/rust-adjudication-gate
Top comments (0)