Entry 05Developer tooling · Go2026

Stopping a call to a function that does not exist

RunEcho checks each edit a coding agent is about to write against the symbols (function, type and constant names) that your code declares. When the edit uses a bare name that is not declared anywhere, RunEcho stops it. The check takes about 12 ms and covers one kind of mistake: on a set of nine confirmed hallucinated names, it caught four.

per check~12 ms
context cost, clean check0 tokens
false positives among flagged symbols15.3%
hallucinated names caught4 of 9
models, keys, networknone

A deterministic check: same input, same answer

Each check parses the edit and looks its names up in an index built from your code. No model is involved, so the same code and the same index give the same answer on every run, machine and agent. The check needs no API keys, network, build or language server (the background process an editor queries for code information). Claude Code can now report type errors after an edit when a language-server plugin is installed; RunEcho checks before the edit is written, without one.

A clean check costs zero context tokens (tokens are the units a model reads and is billed for). The hook writes nothing unless it stops an edit, and then writes about a hundred tokens. Because it runs as a hook, the agent spends no context deciding whether to call it. The companion server, which answers structural questions about the code on demand, is a separate piece and does use context: its tool schemas (the descriptions of its tools that the model is given) take around 968 tokens at session start. Both figures are published in the repository.

How often it is wrong, and how that was measured

The first idea was to count how often the user overrides the guard. That gave nothing to measure: across thirty days of traffic, all 308 gated edits were approved and none were denied. A rate from that data would have called the guard perfect while only reflecting the user’s willingness to approve.

So each flagged symbol is judged against dated git history: whether it was defined when the guard objected, and whether it is defined now. Each flag falls into one of three groups.

Verdict on a flagShareMeaning
Stands51.0%a reference to something that does not exist
Premature33.7%the symbol was absent when flagged and defined later, as when an agent writes a caller before the function it calls
False positive15.3%the symbol was there and the guard was wrong

The shares are of flagged symbols only. The 51% therefore says nothing about how much of an agent’s output is hallucinated.

What RunEcho checks and what it misses

RunEcho checks unqualified references, meaning names used on their own: bare function calls, constant references and type annotations. It was tested on fifteen hand-verified mistakes taken from live session transcripts, each confirmed by a compiler or runtime error. Nine of the fifteen are hallucinated names, and RunEcho catches four of those nine.

The five hallucinated names it misses are qualified references, where a name is accessed through an object: df.groupby(…), tree.Root(). Checking those needs receiver-type inference (working out what type the object on the left is), a semantic analysis RunEcho does not do. The index also covers more languages than the guard checks: shell, Rust and Ruby feed the index but are not checked at edit time.

It is meant to be used the way a type checker is used: one layer that removes one class of mistake, next to the tests and review that catch the rest.

Why an edit-scope contract belongs to a task

Besides checking symbols, the guard can check edits against an edit-scope contract. A contract declares what a piece of work is allowed to touch, so the guard can object when an agent edits outside it. The planned next step was to bind a contract automatically when a session starts.

That plan ended on the day the guard was merged, while the guard was being used on its own development. The contract went stale within the same session, at the moment the work it described was merged. A session often spans several unrelated pieces of work, and a contract describes only one of them. Between tasks the correct state is no active contract, in which case the guard makes no contract check and writes nothing. A contract bound per session would keep enforcing an outdated scope and produce both wrong flags and wrong passes.

How each language’s parser is chosen

Each language gets one of two engines, chosen by one test: whether the language has constructs that a masker cannot tell apart without parsing. A masker blanks out strings and comments while keeping every character in place, so a regular expression (regex, a text-pattern match) can search the rest without being fooled by a name inside a string. Languages that fail the test get a full tree-sitter grammar (a parser that builds a syntax tree). The others use a regex plus a masker.

LanguageEngineWhy
Rusttree-sitter grammarlifetimes vs char literals; nested block comments
Shellregex + maskerquoting and heredocs resolve in one stateful pass

The test is about ambiguity because of how a masker fails. When it guesses wrong it fails silently and loses every symbol after the mistake, and the result looks the same as a file with no symbols, so nothing in the output shows that the error happened. In Rust, a single quote can begin a lifetime such as 'a (a label the compiler uses to track how long a reference stays valid) or a character literal such as 'a' (one character written in quotes), and only parsing tells them apart. In shell, quoting rules and heredocs (blocks of literal text embedded in a script) can be resolved in a single pass that tracks state, so a masker is enough.

Which names get extracted follows each language’s visibility rules. Go extracts only exported (capitalised) names, because an unexported Go name cannot be referenced from outside its package. Rust extracts every name, because calling a private function from elsewhere in the same crate (Rust’s unit of compilation, such as one library) is ordinary, and filtering private names out would miss the common case.

Reducing false alarms and per-edit cost

Duplicate-symbol warningsA build constraint is a line in a Go file that limits which platforms the file is compiled for. Build-constraint pairs (the same function defined once per platform) produced 91% false positives. The warning is now suppressed only when both files carry a build constraint, which removed all of those false positives without calling out to the Go toolchain. A pair with one constrained and one unconstrained file still warns.
Store accessChecking the contract meant opening the store a second time, measured at +9.5 ms per edit. Reusing the store already opened by the symbol lookup that was running brought that down to +0.36 ms.

What security work RunEcho needs

RunEcho runs locally behind a firewall and has no web attack surface. Because the binaries are distributed publicly, the release pipeline is in scope for security work. Authentication and rate limiting are out of scope.

Developer ToolingGo Tree-sitterAgent Safety

For questions about the approach, email [email protected] · Back to portfolio