// SPDX-License-Identifier: CC-BY-SA-4.0 // Copyright (c) Jonathan D.A. Jewell // SPDX-FileCopyrightText: 2024-2026 Jonathan D.A. Jewell (hyperpolymath) = Harvard von Neumann Dehallucinator :toc: :toc-placement: preamble

// ── Licensing ─────────────────────────────────────────────────────────────── image:https://img.shields.io/badge/Code-MPL–2.0-blue.svg?logo=mozilla[Code licence: MPL-2.0,link=“https://opensource.org/licenses/MPL-2.0”] image:https://img.shields.io/badge/Docs-CC–BY–SA–4.0-blue.svg?logo=creativecommons[Docs licence: CC-BY-SA-4.0,link=“https://creativecommons.org/licenses/by-sa/4.0/”] image:https://img.shields.io/badge/Provenance-Quantum–Safe-blueviolet[Quantum-Safe Provenance,link=“docs/legal/EXHIBIT-B-QUANTUM-SAFE.txt”]

// ── Standard & quality gates ──────────────────────────────────────────────── image:https://img.shields.io/badge/RSR-Rhodium_Standard-9C27B0[Rhodium Standard Repository,link=“https://github.com/hyperpolymath/rhodium-standard-repositories”] image:https://api.scorecard.dev/projects/github.com/metadatastician/hvn-dehallucinator/badge[OpenSSF Scorecard,link=“https://scorecard.dev/viewer/?uri=github.com/metadatastician/hvn-dehallucinator”] image:https://sonarcloud.io/api/project_badges/measure?project=metadatastician_harvard-dehallucinator&metric=alert_status[SonarQube Quality Gate,link=“https://sonarcloud.io/summary/new_code?id=metadatastician_harvard-dehallucinator”] image:https://archive.softwareheritage.org/badge/origin/https://github.com/metadatastician/hvn-dehallucinator/[Archived in Software Heritage,link=“https://archive.softwareheritage.org/browse/origin/?origin_url=https://github.com/metadatastician/hvn-dehallucinator”]

// ── Provenance & ecosystem ────────────────────────────────────────────────── image:https://img.shields.io/badge/Zig-Zero–overhead-F7A41D?logo=zig&logoColor=black[Zig Zero-overhead FFI,link=“https://github.com/hyperpolymath/typed-wasm”] image:https://api.thegreenwebfoundation.org/greencheckimage/github.com[Green Web,link=“https://www.thegreenwebfoundation.org/green-web-check/?url=github.com”]

An external state-management orchestration framework for LLM agents: task state lives outside the context window, and only an independent verifier may write COMPLETE.

[IMPORTANT]

This file is a template. You are reading README.adoc from the RSR template repo (or a freshly-cloned copy of it). Run just repo-init to replace every {{PLACEHOLDER}} token with your project’s details, then delete this admonition. Until you do, the {{...}} markers below are intentional placeholders, not content. ====

== What this is

A new repository scaffolded from the Rhodium Standard Repository (RSR) template: a batteries-included starting point that ships with CI/CD, machine-readable project metadata, an AI-agent gatekeeper protocol, a formally-typed ABI/FFI seam (Idris2 + Zig), container and reproducible-build scaffolding, and governance infrastructure — all wired and passing the RSR validators on day one.

Replace this section with a description of your project once initialised.

== Quick start

[source,bash]

1. Create a repo from this template (or clone it), then from the repo root:

just repo-init # interactive bootstrap: fills every {{PLACEHOLDER}}

2. See the available tasks:

just # lists all phases (build, test, validate, audit, …)

3. Check the repo still satisfies the RSR shape:

just validate # structure + metadata checks

just repo-init prompts for the project name, owner, author, licence contact, and the other values listed in .machine_readable/ai/PLACEHOLDERS.adoc, substitutes them across the tree, validates the result, and (if available) runs the k9-svc checks.

== What you get

== Repository map

[cols=“1,3”] |=== | Path | What lives there

0-AI-MANIFEST.a2ml | Universal entry point for AI agents (read first).
.machine_readable/ | Project metadata, policies, contractiles, AI configs.
src/interface/ | Typed ABI (Idris2) + FFI (Zig) + generated headers.
docs/ | Onboarding, status, governance, practice, decisions.
build/, Justfile | Task orchestration (just phases delegate to build/just/*.just).
.github/ | Workflows + community health files.
tests/, benches/ | Test suites and benchmarks.

|===

== The Concept

[NOTE]

The original README was truncated mid-sentence by a shell-escape bug at the moment it was generated (2026-08-23), so the concept was never fully written down. The section below is reconstructed from the surviving fragment and from meta-repos/metadatastician-governance/architecture/ADR-2026-STACK-MIGRATION.adoc. It is marked for owner review: the original design conversation is not on disk and has not been invented here. ====

Standard LLM interactions function like a Von Neumann architecture: the instructions (global rules, system prompts) and the data (logs, execution results, context history) are mashed together into a single sequential memory space — the context window. Over time the expanding data overwrites or pushes out the instructions, leading to goal drift and hallucinated completion: the agent loses the definition of “done” while retaining the confidence to declare it.

(The sentence above is where the original file was cut off, at leading to \.)

The failure is not a lapse in reasoning; it is structural. Anything the agent can write, the agent can overwrite — including its own record of what remains. A longer context window postpones the collapse rather than preventing it.

The fix is a Harvard architecture: separate the two memories.

[cols=“1,2,2”,options=“header”] |=== | | Von Neumann (default) | Harvard (this project)

Instructions | in the context window | in the context window
Task state | in the context window | in an external store the agent cannot write
“Done” decided by | the agent’s recollection | an independent verifier

|===

Task state lives in state/state.txt, which is local and untracked: it binds an absolute, machine-specific target, so Engine init <n> <target> or Engine init-from <target> creates it on each machine. Progress is measured by engine/verify_register.sh, run on the target directory bound when the baseline was set. The agent may request a re-measurement; it may not supply the result, and it may not choose what is measured.

== The Guarantee

completed and status are only ever derived from the verifier, run on the bound target. There is no code path from a command-line argument to the string COMPLETE.

This is the whole point of the project, and it is the thing the original implementation did not do — see <<The Incident (2026-08-23/24)>> below.

When the engine regresses or refuses, it cites the evidence instead of a bare verdict. If the state file says COMPLETE and the verifier counts more than zero, update prints a WITNESS regress block with two readings of the recorded state, as recorded (remaining 0) and as measured. Both fit the record and they disagree on COMPLETE, so the record alone never decided it. If no count can be taken, a WITNESS refuse block says there is no measured case to derive COMPLETE from, and a recorded COMPLETE is demoted. Both blocks go to the command’s output, never to the state file. The underlying fact is proved in the Agda kernel against a model of the update (verification/proofs/agda/Fibre.agda). Its status, and what is not yet proved, is in docs/status/PROOF-STATUS.adoc.

=== Usage

[source,text]

Engine init set the baseline explicitly; bind the target Engine init-from set the baseline by MEASURING the target; bind it Engine attempt record an attempt (arms the circuit breaker) Engine update re-measure the bound target and record progress Engine verify print the bound target’s count; no state change Engine status print current state, the bound target included —-

Run with runghc engine/Engine.hs <command> (needs only GHC — process, directory and filepath are boot packages) or compile with ghc engine/Engine.hs.

The repo root is found by walking up from the working directory, or from $HARVARD_ROOT. The engine is not cwd-dependent.

Exit codes: 0 ok · 1 bad state, bad argument value or stopped engine · 2 usage · 3 circuit breaker tripped · 4 verification could not be obtained (by update or by verify).

=== State file

state/state.txt, five positional lines: totalItems, completed, attempts, status, target. Counts are natural numbers, completed is at most totalItems, and totalItems is at most 10^12. Status is one of RUNNING, COMPLETE, EMERGENCY_STOP. target is the canonical absolute path bound at the baseline. A file that breaks any of these is refused with the field named, never acted on. A four-line file from before the target was bound is refused too: set the baseline again with init-from. Writes are atomic (temp + rename).

=== The circuit breaker

attempts > totalItems + 5 writes EMERGENCY_STOP, which is terminal: further commands are refused until the state is reset deliberately.

== The Incident (2026-08-23/24)

This repository is also its own worked example. Preserved verbatim in the root commit, before any repair:

The cause was a type signature. The original engine had:

[source,haskell]

updateCompleted :: Int -> IO () updateCompleted remaining = … let newStatus = if remaining == 0 then “COMPLETE” else status st —-

remaining was a caller-supplied argument, and verify_register.sh was never invoked by anything. The verifier existed as an orphan file. So the framework built to stop an LLM hallucinating completion took the LLM’s word for completion — putting the progress number back inside the agent’s writable space, which is precisely the Von Neumann collapse described above.

The repair changes that signature to FilePath -> IO () and derives the number. That is the entire fix, and it is about ten lines.

The lesson, stated so it is not lost again: a verifier that is not wired in is not a verifier. If nothing in the system can fail, nothing in the system is checked.

== Known scoping question (needs an owner decision)

verify_register.sh prunes */developer-ecosystem/rescript-ecosystem as a vendored sub-ecosystem (~14,162 files). It does not prune the equivalent tree inside hyper-repos/developer-ecosystem-recovery-20260824/rescript-ecosystem, because the directory name differs. That snapshot is the single largest surviving cluster (~7,170 files) and it dominates the headline count. Whether a recovery snapshot should count toward “remaining” is a scoping decision, not a bug, and has been left alone deliberately.

Related: the original -not -path "*/proven/*" exclusion never excluded what it was aimed at — repos/proven and hyper-repos/proven contain zero ReScript files. It only suppressed 5 real source files elsewhere. It is now anchored to the repo-root level, and those 5 files are counted.

== Where to go next

== Licence

Code, configuration and scripts are link:LICENSE[Mozilla Public License 2.0] (MPL-2.0); prose documentation is CC-BY-SA-4.0. Both texts live in LICENSES/, and per-file SPDX-License-Identifier headers are authoritative. The GitHub-detected licence is MPL-2.0 (the root LICENSE). Long-term attribution uses Quantum-Safe Provenance — see link:docs/legal/EXHIBIT-B-QUANTUM-SAFE.txt[the Quantum-Safe Provenance exhibit].