Topic · DiggingBeagle record
Behavioral fidelity of AI-generated code
A compiled or passing build does not establish that regenerated program transitions preserve reference behavior.
- Topic kind
- mechanism
Definition & limits
Behavioral fidelity is the degree to which model-generated code preserves the relevant observable behavior of a reference implementation or an explicit specification. It includes successful and reverted calls, returned data, emitted events, state transitions, permission checks and effects on other systems. Syntax validity and type checking establish only that a program can be built.
In SolBehave, researchers regenerate function bodies in existing Ethereum contracts and compare results with originals using three distinct oracles. Differential fuzzing varies function inputs; historical replay preserves actual ordered transactions; DCR-guided replay generates valid stateful sequences that had not necessarily occurred on-chain. Under the bounded tests, only 31.4% of pooled compiling function bodies were equivalent, and the coverage differences show why no single oracle can substitute for the others. These rates are experimental observations from a filtered cohort, not a frequency estimate for exploitable deployed contracts.
FALCON extends the behavioral-evidence principle to secure code repair. It verifies execution traces produced by candidate counterexamples before presenting them as repair feedback, then evaluates whether a revision preserves both functionality and security. Monitor-Validity highlights an additional boundary: even when a detector identifies risky input, adapters and tool mediation must still carry that verdict through to a blocked action.
A credible test report must name its reference or specification, initial state, generated sequence, observable outputs, environment and stopping condition. Passing those particular tests is not proof of mathematical equivalence under every possible state. The assurance is only as broad as the oracle and effect checks actually executed.
State can diverge before outputs do
AIChipBench regraded 69 accepted decoder designs and found 45 failures within 32 steps. Five failed only the persistent-state check over that horizon. Extending output tests and observing state earlier therefore reveal different parts of the defect; one cannot stand in for the other.
The tested reference must specify which stored state, reset transitions and memory-stall behavior matter to later results. Reference designs stayed exact in the same regrading, which supports attributing the mismatch to the generated implementations within those tests. The finding neither proves universal equivalence of the references nor establishes corruption in deployed accelerators.
Examples
- A generated Solidity withdraw body compiles, but fails after a permitted initialization and withdrawal sequence.
- A security patch fixes a shown test but fails independently held-out functional or exploitation checks.