The system in question is a Python trading system written entirely by an AI from one 240-line specification document. That origin makes it unusually inspectable. Each requirement in the spec can be traced to the code meant to implement it, so you can see exactly where intent survived and where it did not. This note covers a case where the requirement was not forgotten. It was implemented, and then the surrounding code neutralized it.

What did the specification require when market data contains NaN?

The spec states the rule directly: on NaN, halt trading, do not assume zero. The rule has two clauses, and each blocks a different failure. The first requires the system to stop. The second forbids the quiet alternative, which is substituting a default value and carrying on. Treating a missing price as zero is a classic way to produce numbers that look valid and are wrong. The spec author anticipated that and ruled it out explicitly.

How did the generated code implement the NaN rule?

The detection half is correct. The market data model checks for NaN and refuses to continue with it. It does not assume zero. In that narrow sense, the second clause of the rule was honored.

The failure is in what the check raises. Each NaN case raises a plain ValueError. The codebase already contains a purpose-built SystemHalt exception, and that is the only exception the system treats as an instruction to stop. The counts are exact: there is 1 halt exception type defined, and 0 of the NaN raises use it.

Why does a catch-all handler turn a halt into a log line?

The main trading loop wraps each cycle in a catch-all exception handler. When the ValueError from the NaN check reaches it, the handler swallows the exception, logs it, and continues to the next cycle. SystemHalt is the only exception that gets past this treatment and actually halts.

So the specified behavior, halt trading, is demoted at runtime to a log entry, and the loop keeps running. No single line of code is obviously wrong. The check is right. The handler does what catch-all handlers are written to do, which is keep a long-running loop alive through unexpected errors. The defect exists only in how the two interact. The raise site chose an exception type that the loop is designed to survive.

Why is this kind of defect hard to catch in review and testing?

Each component passes inspection on its own. A reviewer reading the data model sees a NaN check that raises, which matches the spec. A reviewer reading the main loop sees a defensive handler plus a dedicated halt path, which is also reasonable. A unit test that asserts the data model raises on NaN would pass. Nothing fails loudly, because suppressing loud failures is the handler's job.

The gap only appears when you trace the spec's required outcome, trading stops, from the point of detection all the way to the loop's control flow. A check that exists is not the same as a check that has the specified effect.

What does this reveal about how much of a spec survives into AI-written code?

The pieces were all present. The spec named the rule. The code detected the condition. The codebase had a dedicated halt mechanism. What did not survive was the connection between them. The generated code reached for the generic exception type at the raise site instead of the one the system's own architecture reserved for halting.

For anyone auditing AI-generated code against a specification, this changes the question you ask. "Is there code for this requirement?" would have returned yes here. "Does violating this requirement produce the specified outcome end to end?" returns no. Safety-critical rules such as halt, reject, and refuse need the second question.

How do you stop catch-all handlers from swallowing halt conditions?

In general, a halt condition should be expressed through a mechanism the catch-all cannot absorb by accident, and its effect should be verified at the loop level, not at the raise site. Practical options include:

The lesson from this system is narrow but transferable. When a spec says stop, the exception type at the raise site determines whether the system actually stops.