The Model Proposes, the Machine Decides: A Governed Local Agent in One File

The Model Proposes, the Machine Decides: A Governed Local Agent in One File
Everyone wiring agents onto local models has met the same uneasy question: what stops the model from doing something it should not? The usual answers are prompts — "please be careful", "do not exfiltrate data" — which are requests, not controls. A prompt can be argued with. The model in the loop is a probability distribution, and a probability distribution is not an authority.
So I built the alternative and ran it on my own machine, end to end, with the
output left in. One Python file. Standard library only. A local Ollama server
serving qwen4:35b-a3b-nvfp4 — a 35 GB mixture-of-experts on hardware I own.
No cloud calls anywhere in the loop.
The agent was given one question:
What does it mean to run AI systems on hardware you own, and what must be true for such a system to be trustworthy?
And one corpus: six public posts from this site's research archive. It could search the corpus, read a file, assert a claim with a cited passage, or finish. That was the entire allowlist.
The boundary is the whole idea
The architecture has four parts, and only the first one is the model:
- The model proposes. Each turn, the local model emits exactly one JSON
operation:
{"op": "search", ...},{"op": "read", ...},{"op": "claim", ...}, or{"op": "finish", ...}. - A deterministic boundary decides. An allowlist check, a schema check, a
path check.
readaccepts a bare slug — not a path, not a URL, nothing with../in it.claimrequires a file that exists in the corpus and a passage that is a non-empty string. Anything else is refused, and the refusal is written to the audit log. - An executor runs one operation. Search scores the corpus. Read returns one file. Nothing else exists for the model to reach.
- A validator measures. Every claim's passage must appear, verbatim, in the cited file — whitespace-normalized substring match, checked by deterministic code after the run. A claim that fails is dropped and listed as dropped. The model never grades its own homework.
Every decision — permitted or refused — is appended to audit.jsonl with a
SHA-256 hash of the proposed operation. Refusals are logged, not hidden.
What actually happened
The run, verbatim from the console log:
[step 01] PERMITTED search query='local AI hardware ownership trust'
[step 02] PERMITTED read file=2026-11-04-architecture-of-reliable-intelligence.md
[step 03] PERMITTED search query='computational sovereignty local inference hardware ownership'
[step 04] PERMITTED read file=2026-11-18-running-zcode-agent-with-local-ai.md
[step 05] PERMITTED read file=2026-12-03-qwen4-35b-a3b-mlx-local-hermes.md
[step 06] REFUSED (no parseable JSON operation)
[step 07] PERMITTED claim file=2026-11-18-running-zcode-agent-with-local-ai.md -> VERIFIED
[step 08] PERMITTED claim file=2026-11-18-running-zcode-agent-with-local-ai.md -> VERIFIED
[step 09] PERMITTED claim file=2026-11-04-architecture-of-reliable-intelligence.md -> VERIFIED
[step 10] PERMITTED claim file=2026-11-04-architecture-of-reliable-intelligence.md -> VERIFIED
[step 11] PERMITTED claim file=2026-12-03-qwen4-35b-a3b-mlx-local-hermes.md -> VERIFIED
[step 12] PERMITTED claim file=2026-12-03-qwen4-35b-a3b-mlx-local-hermes.md -> VERIFIED
[step 13] PERMITTED claim file=2026-12-03-qwen4-35b-a3b-mlx-local-hermes.md -> VERIFIED
[step 14] PERMITTED finish
[boundary probe] exfiltrate -> REFUSED: op 'exfiltrate' not in allowlist
['claim', 'finish', 'read', 'search']
Step 06 is the honest part. The model emitted a message with no parseable JSON operation. The boundary refused it, logged the refusal with a hash of the raw message, and told the model to emit a corrected operation. The loop continued. A system that hides its refusals is a system you cannot audit; a system that logs them is one you can.
Final tally, from run-stats.json:
{
"steps_used": 14,
"finished": true,
"boundary": { "proposed": 15, "permitted": 13, "refused": 2 },
"claims_verified": 7,
"claims_dropped": 0,
"boundary_probe": {
"op": "exfiltrate",
"permitted": false,
"reason": "op 'exfiltrate' not in allowlist"
}
}
Fifteen operations proposed. Thirteen permitted. Two refused — one malformed
message, one deliberate probe: after the run I fed the boundary an
{"op": "exfiltrate", ...} operation, the kind of thing a jailbroken agent
might attempt. It was refused by the allowlist and written to the audit log.
The probe is labelled as a probe in the output, because a demonstration that
does not distinguish its own tests from its results is not a demonstration.
Seven claims came back verified. I re-checked them independently of the script — extracted each cited passage from the generated briefing and matched it against the corpus files with a separate checker: 7 of 7 passages present, 15 audit records, every record hashed. The claims are not decorative. One of them, for example:
Trust in a local AI system is earned empirically: every command actually run, every number taken from real output, and every failure documented rather than asserted. — source:
2026-12-03-qwen4-35b-a3b-mlx-local-hermes.md
The model found that passage in a post about running a 35B MoE on a 48 GB Mac and cited it as an answer to a question about trust. It did not paraphrase it into something smoother. The validator would have refused a paraphrase.
What this proves, and what it does not
It proves the shape works: a local model can do multi-step research inside a deterministic envelope, and the envelope holds. The model never once reached outside the allowlist — not because it was asked nicely, but because the executor does not exist for anything else.
It does not prove the model is wise. The claims are only as good as the corpus, and the corpus is six posts I wrote. The boundary is small on purpose: four operations, one corpus, one question. The point of the experiment is the architecture, not the intelligence. Swap in a bigger corpus, a governed executor with real side effects, an evaluation gate instead of a substring check — the shape does not change. The model still proposes. The machine still decides.
That shape is the part nobody tutorials cover. The local-AI boom produced the hardware and the weights; the open question is what you build on top once the weights are yours. An agent that can act is an agent that can be wrong with consequences. The mitigation is not a better prompt. It is a boundary: an allowlist the model cannot edit, a validator it cannot argue with, and an audit trail that records every refusal.
Reproduce it
One file, standard library only, a local Ollama server:
python3 sovereign_briefing.py # needs Ollama + any markdown corpus
The script prints every decision as it happens, writes briefing.md,
audit.jsonl and run-stats.json, and exits nonzero if the loop did not
finish or no claims verified. The full source ships with the demonstration
repo; the run in this post is the archived one, refusals and all.
This demonstration was built as a companion to Computational Sovereignty: Building Local-First AI Systems — the long-form version of the argument above, including the governance and verification chapters this one-file sketch leaves out. The free first chapter is here, no gate: https://www.danielkliewer.com/sample. The book: https://www.danielkliewer.com/book.
Related research
Jul 14, 2026
The Recursive Research Compiler: Turning Compile-Time AI Inward with the Knowledge Compiler SDK
A case study in Compile-Time AI: how the Knowledge Compiler SDK turns Markdown into inspectable intermediate representations, and how pairing it with an agent like Hermes lets a codebase compile its own next generation of passes.
Jul 5, 2026
Local AI Architecture: Running Models on Your Own Hardware
Your practical guide to running AI on your own hardware. Ollama setup, model selection, hardware requirements from $2K to $50K, and wiring local inference into a sovereign pipeline.
Jul 2, 2026
Building Autonomous Sovereign AI: How Autoresearch Loops and Expert Fine-Tuning Create Self-Improving Local AI Systems
How to build self-improving AI systems using autoresearch loops, agent recipes, and domain-specific fine-tuning with open-source tools. A complete implementation guide connecting the latest research from Introspection, Bridgewater AIA Labs, and Thinking Machines Lab.
Mar 26, 2026
DeerFlow 2.0: Building Sovereign AI Agent Systems with Local-First Architecture
Learn how DeerFlow 2.0 bridges the execution gap in AI with its SuperAgent harness, AIO sandbox, and persistent memory. Complete guide to building sovereign, local-first AI agent systems.
Dec 5, 2026
THE OPERATOR: Reproducing a 30-Second Analog-Horror AI Short Entirely on Local Models
A 30-second vertical analog-horror short about autonomous AI, produced end to end on one 48 GB Apple Silicon Mac — Qwen image generation, Qwen3-TTS narration, a procedural numpy score, and an ffmpeg/PIL frame renderer. No cloud calls in the generation path. The full pipeline, its data contracts, and the memory wall that shaped it.
Dec 4, 2026
How an Agent Built a Full Book-Marketing Campaign — and How You Can Replicate It
A reproducible recipe for turning a published technical book into a full marketing campaign — memes, ads, posters, narrated video, social and educational copy, and a distribution package — built end-to-end by an agent on local hardware, with every asset verified before it ships.