- Write equal-priority and source-mutation examples for the grouping fixture.
- Check one metamorphic relationship against the proposed refactor.
- Separate any intended tie-break change from the behavior-preserving patch.
A refactor promises to change structure while preserving observable behavior. Generated cleanup can accidentally alter ordering, mutation, exceptions or performance assumptions. Define which observations matter in the fictional module, then evaluate the transformation against those invariants rather than its apparent elegance.
Choose the observable boundary
The fixture groups support tickets by priority while preserving arrival order inside each group. The helper currently returns a new array and leaves the original untouched. These are observable promises even if the code is repetitive. Write examples with equal-priority tickets and shared object references. Ask the assistant to explain which behavior its proposed sorting function preserves, but inspect the language’s mutation and comparison semantics yourself before accepting the replacement.
Use metamorphic relationships
Besides fixed examples, test relationships that should remain true. Adding an unrelated low-priority ticket should not reorder two existing high-priority tickets. Running the grouping twice should not progressively mutate the source array. Such properties can expose a plausible-looking implementation that passes one snapshot. Keep the properties tied to real requirements; do not create arbitrary tests that merely freeze an accidental implementation detail without understanding why a caller depends on it.
Separate semantic changes for review
If the team actually wants a new tie-break rule, name that as a feature change with its own expected outputs. Do not hide it inside the refactor label. Review exceptions, asynchronous behavior and data allocation where they matter to the contract. An AI reviewer is useful for generating possible counterexamples, but its own agreement with the generated patch is not independent proof. The final note should describe preserved invariants and known gaps, not claim equivalence for every possible input.
Fictional worked example — Stable grouping
Supplied input
A: high at09:00; B: high at09:01; C: low at08:59
Example result to inspect
High group remains A,B; original input array unchanged
The order and non-mutation claims are explicit fixture invariants that can distinguish a mistaken in-place sort.
This is an authored teaching example, not a recorded live provider run or an independent performance test.
Make the idea concrete.
- Write equal-priority and source-mutation examples for the grouping fixture.
- Check one metamorphic relationship against the proposed refactor.
- Separate any intended tie-break change from the behavior-preserving patch.
What a useful outcome looks like
A refactor violates the stated contract if it mutates an input that callers expect to remain unchanged.
Ask for reasoning you can verify.
Use fictional or permitted data. This is a copyable brief for a separate approved model; no model is called from this article.
Help me review this fictional coding with ai exercise: Separate a behavior-preserving transformation from a feature change. I will supply the original input, my expected result and the actual transformation. Explain stable arrival order, identify unsupported assumptions about semantic change, and propose one bounded negative control. Keep observations separate from hypotheses; do not invent output or act on external systems.
Turn reading into a reviewed checkpoint.
Complete the manual exercise, review each item, then answer the evidence question. This records self-study, not independent assessment of expertise.
Review the checklist and pass the question to save this lesson.
Primary references
References support further checking; cited organizations do not endorse AgentX. This guide is original AI-assisted educational content with illustrative examples. Read the editorial policy or report a correction.
Continue with a related task.
Read the contract before asking for code
Map callers, inputs and invariants before requesting a change.
Request a minimal diff with explicit exclusions
Keep an AI-assisted patch focused enough to review and revert.
Test the requirement rather than the generated implementation
Use independent examples to challenge an AI-written function.