Testing Coding Models on Instruction Following with a Heptagon Ruler-Compass Construction
Many coding models can produce a regular heptagon by dividing a circle into seven equal parts—but that's not what the user asked for. This article uses the classic "ruler with two marks" heptagon construction as a test case to show how to distinguish instruction following from superficial success, covering requirement decomposition, geometry/rendering separation, animation export, acceptance criteria, and controlled testing to evaluate whether a model truly follows specified construction paths.
Testing Coding Models on Instruction Following with a Heptagon Ruler-Compass Construction
Instruction Following Is Not a Checklist
It isn’t hard to get a coding model to generate a webpage demonstrating a regular heptagon—any program that divides the circumference of a circle into seven equal parts will produce seven vertices that look correct. But if the user asks for “constructing a regular heptagon with a two-marked ruler,” computing the vertices directly changes the problem: the deliverable shows the right shape, but not the construction method the user specified.
This distinction matters in everyday development too. Users sometimes specify the goal, the implementation path, and the delivery format at the same time—for example, wanting the final result, requiring the intermediate process to be traceable, and needing the demo exported as an animation. If you only check whether the page shows a heptagon, a play button, and an export button, you can easily judge a delivery as successful even though a critical constraint was bypassed.
So the real value of this test case is not whether the model knows an obscure term, but whether it can convert natural language into a set of executable, verifiable rules: which objects must simultaneously satisfy which constraints, which details are left to the implementer, and which missing pieces of information make the final result indeterminate. A single case can reveal these capabilities, but it cannot represent the model’s performance across all programming tasks.
Decompose the Requirements Before Implementing
1. Rewrite the Informal Description into Verifiable Geometric Constraints
Let D be the bottom-left corner of the square and E the bottom-right corner. Construct the perpendicular bisector of the base DE, then draw an auxiliary circle centered at E with a radius equal to the square’s diagonal. Next, let A and B denote the two marks on the ruler’s edge. “Keep the ruler tight against D” means the line containing the ruler’s edge always passes through D. “The first mark moves along the circle” means A stays on the auxiliary circle, and “the second mark passes through the perpendicular bisector” means B stays on the base’s perpendicular bisector. The distance between A and B must remain the ruler’s fixed mark spacing.
Once rewritten this way, a distinction that an animation could easily mask becomes visible: the task is not to first place A on the circle and then independently snap B onto the bisector, but to find positions satisfying all conditions while keeping the ruler’s edge through D and the mark spacing fixed. If the page treats the two marks as unrelated control points, then even if the final frame appears aligned, the two-marked-ruler operation has not been implemented.
Constraints being satisfied doesn’t imply a unique solution, either. When the ruler’s edge is represented as a line, which side of D the marks fall on, their order along the edge, and whether the demo allows flipping the ruler can all affect which candidate positions are chosen. The program should state its selection criteria explicitly; if the criteria are insufficient, it should display the candidates rather than declaring whichever solution the numerical solver found first to be the correct answer.
2. Distinguish Unit Choice from Actual Length Ratios
The problem doesn’t specify the square’s side length, so the program may normalize it to 1 internally—but that’s only a coordinate choice, not a claim that only a unit square works. Scaling the square, the auxiliary circle, and the mark spacing together leaves the geometric relationships unchanged; changing any one of those lengths alone does change the constraints.
What actually needs to be confirmed is the ratio of the mark spacing to the square’s side length. Setting both to 1 effectively adds the assumption “mark spacing equals side length.” The implementation should document this assumption in the construction notes and validate it against the chosen construction scheme, rather than silently hardcoding it under the banner of “default unit length.” Page zooming should also change only the display scale, never the internal geometric ratios.
3. Don’t Wave Away Indeterminate Derivations as Routine Steps
“After constructing the perpendicular bisectors, find the circumcenter” specifies only the operation type, not the full dependencies. To determine a circumcenter from two perpendicular bisectors, you must first state which chords each bisector comes from, and then explain how those chords’ endpoints arise from the earlier positioning results. The two bisectors must also intersect at a unique point. Otherwise, even if the page draws a few auxiliary lines, nothing connects the final heptagon to the ruler-based positioning.
If a validated construction scheme has been chosen, list each step’s inputs, operations, and outputs, then implement them one by one. If the requirements are insufficient to determine the intended scheme, it’s appropriate to first ask about the mark spacing ratio, the chosen branch, the marking order, and the construction rules after positioning; alternatively, deliver the positioning demo first and clearly flag the derivations as not yet implemented. Generating seven points by dividing the circle evenly and then drawing a few plausible-looking auxiliary lines does not count as filling in the steps.
Separate Construction, Presentation, and Export
1. The Geometry Layer Owns Correctness; the Rendering Layer Owns Display
The geometry layer stores the original points and construction rules, computing lines, circles, intersections, and the ruler’s candidate positions. The rendering layer converts these objects into on-screen segments, arcs, and markers. Screen coordinates must never feed back into geometric computations; otherwise, a narrower window, zooming, or coordinate rounding could give the same ruler different positions on different devices.
Every derived object should also record the upstream objects it depends on. For example, the circumcenter should reference the two perpendicular bisectors used in the intersection, not a fixed coordinate detached from the construction steps. That way, when an upstream parameter changes, the program can recompute downstream objects; and when a step has no valid result, it can halt and report the specific failure condition instead of reusing the leftover figure from the previous run.
2. Animation and Final Positioning Must Use the Same Constraints
During the ruler animation, A can move along a candidate arc of the auxiliary circle; the ruler’s edge direction is then determined from D and A, and B is computed from the mark spacing and the marking order. Throughout this search, three conditions—A on the circle, the ruler’s edge through D, and the fixed mark spacing—always hold. B’s distance to the perpendicular bisector then indicates when positioning is complete.
Computationally, the signed deviation of B relative to the bisector can be used to find candidate solutions. When the deviations at the two ends of a continuous interval have opposite signs, the search interval can be narrowed further—but checking only for sign changes can miss cases where B is tangent to the bisector, so you cannot claim to have found all solutions without verification. The implementation must also handle degenerate positions, such as D coinciding with A, where the ruler’s edge direction is indeterminate. The animation’s final frame should use the actual valid position found—not forcibly snap B onto the target line for visual smoothness.
3. Define Display Rules for “Necessary Traces”
The auxiliary circle can be complete for geometric computation, but visually there’s no need to leave every compass movement on the canvas. A practical approach distinguishes three categories: construction lines that explain the basis for intersections or positioning; the ruler body, compass motions, and search trajectories shown only for the current step; and the outlines and key markers needed for the final display.
The default view can keep only the arcs and intersections a reader needs to verify the construction, with a full auxiliary view available for inspection. Here it’s important to distinguish “not displayed” from “not participating in computation”: hiding an arc should not delete its corresponding geometric object, and switching display modes should not change the candidate solutions.
4. Let the Animated Export Reuse the Preview Timeline
When exporting a GIF, render frame by frame at deterministic timestamps rather than recording the live preview. Live playback is affected by page load and refresh timing, so key positioning frames may be skipped; independent sampling ensures the initial state, completed positioning, and final figure all appear in the export. Preview and export should use the same step data, visibility rules, and framing, so that auxiliary arcs visible on the page don’t vanish in the file and labels don’t get clipped by the export boundary.
Resolution, frame rate, and file size involve trade-offs; no fixed setting is universally optimal. For geometry teaching demos, whether key frames are legible usually matters more than how smooth the motion is. When export fails, the failure point should be clearly reported—a button triggering a download doesn’t mean the generated file actually plays correctly.
Acceptance Must Verify Both Results and Provenance
First, check intermediate constraints. At the moment positioning completes, compute the distance from D to the ruler’s edge line, the difference between A’s distance to the circle center and the expected radius, B’s distance to the perpendicular bisector, and the difference between the actual and configured mark spacing. Also verify that the marking order matches the chosen branch. Tolerances should scale with geometric size, not with screen pixels, so that zooming can’t flip the same solution between pass and fail.
Then, check the final figure. Verify that the seven vertices are distinct, connected in circular order, equidistant from the circumcenter, and that the seven sides are approximately equal. If necessary, independently check that the central angles between adjacent vertices are close to one-seventh of a full turn. That angle should serve as a test baseline—not be used in reverse to generate the vertices. At the same time, trace the vertices’ construction dependencies to confirm they genuinely come from the problem’s prescribed steps. Correct results and correct paths are two independent acceptance criteria; neither can substitute for the other.
Finally, check interaction and export. After pausing, stepping, dragging the progress bar, and resetting, the same step should present the same geometric state; the construction relationships should survive window resizing. You can also pick a few key timestamps and compare the preview against the exported file, checking that the ruler’s position, auxiliary arcs, text labels, and final outline match. For inputs with no valid solution or multiple candidates, verify that the page reports its status honestly rather than unconditionally playing a success animation.
Use Controlled Tests to Separate Understanding from Completion
The same case can be turned into two prompt groups. One group preserves the informal wording, observing whether the model can identify omitted items, state its assumptions, and ask specific questions when information is insufficient. The other group specifies the mark spacing ratio, marking order, subsequent construction rules, and trajectory retention conditions, observing whether the model can accurately execute a complete specification. Both groups must use the same acceptance criteria so failures can be attributed either to insufficient requirements or to the implementation omitting constraints that were already explicit.
Two controlled changes are also worth adding: first, scale all geometric lengths proportionally to check whether the program preserves the construction relationships; then, change only the mark spacing to check whether the program re-solves—and warns when the original construction no longer applies. The former catches hardcoded coordinates; the latter catches a pre-baked heptagon disconnected from the ruler’s state. Test records should separately note requirement understanding, mathematical correctness, construction traceability, and feature completeness, rather than giving a single vague “done” verdict.
The real value of this case is turning “the model understood” into verifiable facts: the user-specified path still exists, added assumptions are disclosed, and every result can be traced back to the operation that produced it. For complex programming tasks, being able to pinpoint exactly which step needs clarification is often more valuable than delivering a demo that plays start to finish but cannot explain its key derivations.
