← Devlog

Seven bugs that passed validation

The workflow we give agents for writing NAL is simple: write the game, run nal-validate, fix whatever it reports, and repeat until it says ok. That only works if ok means something. On 25 October we found out how little it meant.

The Hollowlight test

We asked an agent to build a game from a prompt: Hollowlight, a 3D action game of about 1,000 lines. Then we planted seven of the mistakes people and agents make all the time, and ran the validator. It passed all seven.

Planted bugWhat happened at runtime
Spawning a template that doesn't existA script error at spawn time
Calling a function with the wrong number of argumentsA script error when the call runs
Writing to a misspelled field, Health.curent = …Nothing visible. It created a new field called curent.
World.get_field(id, "Helth", "current")Nothing visible. It returned 0.0.
A state machine transition to a state that doesn't existNothing visible. The entity got stuck in a state with no body and never ran again.
A system reading a component that isn't in its query:Nothing visible. It worked whenever the entity happened to have that component.
Input.action("dash") with no dash bindingNothing visible. The action never fired.

The first two at least failed loudly once the game ran. The other five did nothing you could see. For a person that means a long debugging session. For an agent it's worse: the validator says ok and there's no error message to work from. This is the same kind of bug as the ones in Bugs that return zero, and the same rule applies: if NAL accepts something, it has to work or be rejected.

Checking names across the whole project

The validator used to parse each file and run style and structure checks. It almost never looked a name up. Now there's a semantic pass that runs over the whole project after imports are resolved, with a new diagnostic for each case:

Here's a small file with six of the bugs planted in it:

planted.nal (excerpt, deliberately broken)NAL
component Health { current: float = 100.0; max: float = 100.0; }
component Enemy { speed: float = 2.0; }

// ...
system Combat {
    query: [Health, Enemy];
    priority: 0;
    transform {
        Health.curent -= damage(5.0, 1.0);
        let hp = World.get_field(Entity.id(), "Helth", "current");
        if (Input.action("dash")) { Entity.spawn_at("Ipm", 0.0, 0.0); }
    }
}
terminalshell
$ cargo run --bin nal-validate -- planted.nal
error[V142]: planted.nal:17:26: state_machine `Brain` state `Idle`: `-> Chasng` is not a state (states: Chasing, Idle)
error[V140]: planted.nal:24:5: component `Health` has no field `curent` (fields: current, max)
error[V144]: planted.nal:24:5: fn `damage` takes 1 argument(s), called with 2
error[V141]: planted.nal:24:5: World.get_field: unknown component "Helth"
warning[V145]: planted.nal:24:5: Input.action("dash"): not in config input_map and not a raw key name — it will never fire
error[V143]: planted.nal:24:5: Entity.spawn_at: unknown template "Ipm" (imported templates must be `pub`)
FAIL: planted.nal — 5 error(s), 1 warning(s)

With those six names fixed, the same file validates cleanly.

One detail took some care. Checks like "this template exists" only make sense for a whole game. A library module validated on its own can spawn a template that's defined in the file that imports it. So the whole-program checks only run on complete scenes, meaning files with a config block. Every planted case is now a test fixture. When we ran the new checks over every .nal file in the repository, they found no new errors and one warning, and that warning was a real unbound action in a test file.

And at runtime

Validation can't catch everything, because some names are only known when the game runs. So we also tightened the runtime:

The query: question needed a decision rather than a fix. Our own agent guide said a system could only touch the components in its query, but the runtime never enforced that. We decided the query picks which entities a system runs on and doesn't limit what it can read, wrote that into the spec, and corrected the guide. A warning for reads outside the query is still on the list.

More of the same family

Hollowlight wasn't the only source. The same week we started prototyping Wyrmworks, a design for a bigger game after Ember Colony, and the VM parity work kept running. Between them they turned up more quiet failures:

All of those are fixed, with tests. Hollowlight also found things that are still open: launching the player with a bare relative path, Input.pressed reporting held state for scripted named actions, MCP playtest heuristics that assume a platformer, and the lack of 3D physics and point lights.

Planting bugs on purpose turned out to be a useful test. A game with known mistakes in it shows what the validator actually catches, which a clean game can't.