How do I check correctness?
Understand the concept
Correctness means the implementation satisfies the required behavior for valid, invalid and concurrent inputs. A review begins with the intended rule, because readable or compilable code can still implement the wrong rule. Trace the inputs, state changes and outputs before judging style.
Important ideas
-
Compare code with the required behavior, including empty and invalid inputs.
-
Trace state changes and check return values.
-
Ask whether concurrent requests can break the rule.
-
Write down an invariant such as “stock cannot become negative” and look for a path that violates it.
Can you explain it without the notes?
How do I check correctness?
Use your own words. Explain an example and one limitation before checking the explanation.
Check your explanation
Correctness means the implementation satisfies the required behavior for valid, invalid and concurrent inputs. A review begins with the intended rule, because readable or compilable code can still implement the wrong rule. Trace the inputs, state changes and outputs before judging style.
Turn this concept into a clear answer.
- Explain the failing input or interleaving clearly enough that another developer can reproduce the problem.
Adapted from 11_AI_CODE_REVIEW.md · “How do I check correctness?”. Examples are study fragments; framework behavior can depend on your version.