How it works¶
anti-hall is built around a Rust engine, ah-engine. It is the core of the plugin,
not an add-on: every hook the assistant's harness fires is answered by it. The guards,
tasks, handovers and the other features are what the engine does;
this page is how it does it.
Status
The plugin fetches the engine binary itself. No Node.js is needed: the Rust engine is the only runtime.
The core: one engine, one thin trigger¶
ah-engine is a small program that stays running in the background, one per user. Each
hook event in the plugin's hooks.json is one thin trigger, the Rust client ah-hook <Event>,
that hands the event to the engine. The engine decides which checks apply to that event
and answers from memory.
Claude Code / Codex
│ hook event, JSON payload
▼
thin trigger ah-hook <Event> (one per event, Rust)
▼
engine client ──socket──▶ ah-engine (one resident process per user)
│ reads at run time, from the plugin:
▼
engine/logic/*.js the rules' logic
engine/defaults/*.toml settings and message texts
This replaced one Node.js process per hook per tool call. The engine's design notes measured the nine pre-tool hooks of a Bash call at about 409 MB of memory combined and 187 ms of CPU, most of it Node's own start-up. The engine answers from one long-lived process of about 5 MB, through a client of about 2 MB.
The plugin owns the rules¶
The engine is a runtime; the rules are the plugin's own files, read when the engine starts, when the plugin updates and when a file changes. Nothing is compiled into the binary.
| What | Where in the plugin | Format |
|---|---|---|
| Logic of each check | engine/logic/<check>.js, with shared helpers in engine/logic/lib/ |
JavaScript, run inside the engine in a sandboxed interpreter |
| Settings, limits, intervals, message texts | engine/defaults/*.toml |
TOML |
| Which checks answer which event | engine/defaults/dispatch.toml |
TOML |
Changing a rule or a message means editing a plugin file, not rebuilding the engine. Your
own overrides live in ~/.anti-hall/settings.json; see Settings.
How a hook call runs¶
Every hook command in hooks.json (31 Claude Code events, 10 Codex events) is generated from one template, so it is the
same for each event:
[ -x "$HOME/.anti-hall/ah-engine/bin/ah-hook" ] && exec "$HOME/.anti-hall/ah-engine/bin/ah-hook" <Event> [--host codex] \
|| exec sh "${CLAUDE_PLUGIN_ROOT}/hooks/install.sh" <Event> [--host codex]
| Situation | What runs |
|---|---|
| Thin client installed | ah-hook takes the call (exec, so a block's exit code 2 reaches the host unchanged). It hands the event to the engine and returns the engine's answer. |
| Engine busy, slow, restarting or broken | ah-hook lets the call through and prints one note per session; it never blocks because something failed. |
| Thin client not installed | hooks/install.sh, the plugin's only shell file: stdout stays empty, exit 0, one stderr notice per session. It downloads nothing unless you opted in. |
Node fallback switch on (ah-engine fallback node, a manual diagnostic) |
ah-hook itself runs the original Node.js hooks from the separate anti-hall-node backup, directly and without a shell. It never switches on by itself. |
No Node.js and no shell script is on a normal hook path. The commands are checked by tests
(ah-engine/tests/it/hooks_files.rs): the plugin ships exactly one .sh file and every command equals the template.
The engine binary and the thin client are installed by sh hooks/install.sh --download (the setup skill runs it) and
checked against a sha256 checksum pinned in the plugin. Supported platforms are the same as the plugin: macOS on
Apple silicon; Linux (including WSL), Apple Intel and native Windows are coming soon.
Binary download and verification¶
The engine is a prebuilt binary, installed on request or by your opt-in, so it is worth knowing exactly what that does. Every point below is read from the code in this repository.
| Question | Answer |
|---|---|
| What is fetched | One archive, ah-engine-vX.Y.Z-<target>.tar.gz, for your platform (macOS arm64/x86_64, Linux x86_64/arm64 on glibc or musl; WSL counts as Linux). Only the single ah-engine file is extracted from it. |
| From where | https://github.com/talas9/anti-hall/releases/download/ah-engine-vX.Y.Z/ over HTTPS (TLS 1.2 or newer, 120 s limit, 128 MB cap). Nothing about you or your project is sent. |
| Which version | The one pinned in plugins/anti-hall/ah-engine.lock, which ships inside the plugin. The version and the sha256 of every asset come from that file, never from the network. |
| How it is verified | The download is installed only if its sha256 equals the lock's entry. There is no trust on first use. The extracted binary must also run and report the pinned version. |
| If it fails | A download error, a checksum mismatch, a binary that does not run, or an unsupported platform installs nothing. The reason goes to ~/.anti-hall/ah-engine/bootstrap.log and the session carries on; until a binary is installed the hooks pass through with one notice per session. |
| Install location | ~/.anti-hall/ah-engine/bin/ah-engine, replaced atomically, previous copy kept as ah-engine.prev. |
| Provenance | Each release carries SHA256SUMS and a GitHub build-provenance attestation, created by .github/workflows/ah-engine-release.yml. Check one with gh attestation verify <archive> --repo talas9/anti-hall. |
| Immutability | Tags v* and ah-engine-v* are covered by a repository ruleset that blocks deletion and updates, and the repository has immutable releases enabled, so a published release's assets and tag cannot be changed. |
| Opt in | Nothing is downloaded on its own. You install it with /anti-hall:setup or sh hooks/install.sh --download; the setting engine.bootstrap = true (or AH_ENGINE_BOOTSTRAP=1, which overrides the setting) makes the download happen automatically on SessionStart. |
What the binary does on the network. The engine runs as a per-user background process that
listens only on a private Unix socket. Its only HTTP client (ureq with rustls) lives in the
opt-in Jev module, which is off by default; with Jev off the engine makes no network
connections. The download above is done by hooks/install.sh (first install) or ah-hook install (later installs and updates), not by the engine. The sources
are in ah-engine/ and the dependency list is ah-engine/Cargo.toml.
Build from source. There is no switch that makes the installer build or fetch from a
different place. What is supported is a binary you put in place yourself: the installer never
overwrites ~/.anti-hall/ah-engine/bin/ah-engine when it did not install it (or when it no
longer matches what it installed), and the thin client runs that file. Leave engine.bootstrap at its default
(false) so a pinned release is not fetched when the file is absent.
git clone --branch ah-engine-vX.Y.Z --depth 1 https://github.com/talas9/anti-hall.git
cd anti-hall/ah-engine
scripts/build.sh # cargo build --release --locked; prints the binary's path and sha256
mkdir -p ~/.anti-hall/ah-engine/bin
cp target/<triple>/release/ah-engine ~/.anti-hall/ah-engine/bin/ah-engine # <triple> as printed by build.sh
export AH_ENGINE_BOOTSTRAP=0 # forces the automatic download off (it is off by default)
The AH_ENGINE_BIN variable is a test-only override and is ignored in normal use. Full
procedure and offline builds from the vendored source archive:
RELEASING.md.
Learn more¶
- Features: what the engine does for you.
- Settings: every setting and its default.
- Engine design and status: architecture, what still runs on Node, and measured results.