How to Evaluate LLM Coding Capability with Complex Coding Tasks

    Determining whether an AI coding tool can truly "write code" requires more than checking syntax or passing sample tests. This article presents two representative task families—a time-windowed shortest path problem with multi-objective optimization and an idempotent replay of out-of-order logs—and explains how to design evaluations, interpret failure modes, and enforce invariants. It also offers a layered evaluation protocol and engineering practices for assessing whether a coding model meets maintainable production standards.

    In real engineering scenarios, judging whether an AI coding tool “can write code” should never rely only on syntactic correctness or passing the provided samples. What truly discriminates between models are tasks with multiple optimization objectives, discrete time constraints, idempotency and visibility rules. These simultaneously test algorithm selection, integer overflow awareness, lexicographic stability, and state machine design. This article starts from two typical task families, explains how to design evaluations, how to interpret failure modes, and which invariants an implementation must preserve. The discussion uses neutral technical language and is not tied to any specific model or vendor.

    1. What Questions Should an Evaluation Answer?

    For developers, a valuable evaluation typically revolves around four things: first, whether the model can precisely translate natural-language constraints into executable invariants; second, whether it chooses the correct complexity at large input scales; third, whether it breaks ties according to the ordering specified by the problem when multiple optimal solutions exist; fourth, whether boundary conditions and hidden pitfalls are handled explicitly. A conclusion of merely “the samples pass” is almost useless for predicting production risk.

    It is therefore recommended to split the evaluation into three layers: semantic alignment, algorithmic correctness, and engineering robustness. Semantic alignment checks whether field semantics, ignore rules, and unreachable return values are consistent with the spec. Algorithmic correctness checks whether the primary and secondary objectives are optimized lexicographically. Engineering robustness checks handling of large integers, multi-edges, empty graphs, self-loops, duplicate keys, and similar issues. Missing any one of the three means the task cannot be considered passed.

    2. Task Family One: Directed Shortest Path with Phase Periods

    The problem abstracts as follows: given a directed graph with vertices numbered 0 to n-1, each edge carries a phase, a period, a duration, and a cost. When arriving at vertex u at time T, you may leave along that edge only if there exists a departure time depart ≥ T such that (depart + phase) mod period equals 0; otherwise you wait until the nearest valid time. The arrival time at the other end is depart + duration, and the cost is accumulated. The required output is a triple: the earliest arrival time, the minimum cost at that arrival time, and the corresponding vertex path. If both arrival time and cost tie, return the lexicographically smallest path; if the target is unreachable, return an empty result.

    Typical constraint scales reach hundreds of thousands of vertices and edges, with times and costs being large integers and the starting time on the order of 10^18. This rules out floating-point arithmetic, naive waiting-time enumeration, and anything other than a properly optimized heap-based relaxation.

    1. Closed-form waiting time

    Given the current time T, valid departure times satisfy depart ≡ −phase (mod period) and depart ≥ T. Let r = (−phase) mod period. If T already satisfies the congruence, no waiting is needed; otherwise the wait is period − ((T − r) mod period). Integer modular arithmetic must be used throughout to avoid cross-language differences in negative modulo behavior. When period is 1, departure is allowed at any moment and waiting is always 0; implementations should treat this as a fast path, otherwise the modulo computation wastes cycles on the hot path.

    2. State design for multi-objective shortest paths

    The primary objective is the earliest arrival, the secondary objective is the minimum cost at that arrival time, and the third is the lexicographic order of the path. The correct approach is to carry both arrival time and accumulated cost in the state, with the relaxation rule: if the time is better, replace entirely; if times tie, compare costs; if both tie, compare paths (or a reconstructable predecessor sequence). Cost must not be the first sort key, otherwise a “cheaper but later” incorrect solution will be produced.

    Path lexicographic order cannot be patched up with an arbitrary post-hoc DFS. Either compare full vertex sequences during relaxation, or compare a lexicographic invariant of “current vertex sequence plus the edge to be taken.” When costs are zero and multiple time-equivalent edges exist, incorrect predecessor overwriting will yield a path that is not lexicographically minimal. Multi-edges must all be inserted into the graph and must not be deduplicated by (u, v).

    3. Scale and numeric pitfalls

    The sizes of n and the edge count dictate a heap-optimized labeling algorithm, with relaxation count on the order of the edge count. Adding time and duration may exceed the “seemingly safe” range of signed 64-bit integers, so a sufficiently wide integer type must be used explicitly, and floating-point time representation is forbidden. When s equals t, the earliest arrival is the starting time, the cost is 0, and the path is a single vertex; if self-loops are still relaxed, a positive duration may introduce a spurious “better” result. Unreachable must be distinguished from “reachable at enormous cost”—return the agreed empty value rather than a sentinel path.

    4. Common failure modes

    The worst evaluation results tend to concentrate on: failure to handle period = 1; zero-cost parallel paths; identical earliest times but different lexicographic paths; source equal to destination; large integer overflow. These are not corner cases but explicitly specified hidden pitfalls. If a model writes only a “Dijkstra + waiting formula” skeleton without tie-breaking and path comparison, it should be judged incomplete.

    3. Task Family Two: Idempotent Replay of Out-of-Order Logs

    The second task family simulates collaborative editing or object storage metadata: events arrive out of order, with fields including timestamp, actor, idempotency key, operation type, and payload. Types are limited to add, transfer ownership, delete, and snapshot. Each object in the system has an identifier, an owner, and a value. The replay order must be ascending by timestamp, then actor, then idempotency key; within the same actor, a duplicate idempotency key takes effect only the first time. Add creates only if the identifier does not exist; transfer and delete take effect only when the current owner equals the actor; snapshot records the visible state of the specified identifier at that moment, or empty if it does not exist.

    1. Sorting and idempotency are prerequisites for correctness

    Applying events in arrival order and sorting afterwards produces non-reproducible results. The full event set must be stably sorted first, then scanned linearly. The idempotency set should be indexed by (actor, op_id); on a hit, the entire event is ignored, including snapshots. The ignore check must happen before the “is authorized” check, otherwise duplicate deletes may be incorrectly skipped or executed twice.

    2. Ownership and visibility

    On add conflicts, ignore rather than overwrite, so that the first creator (by sort key) becomes the owner. Transfer is a single-point ownership change and does not modify the value. Delete removes the object, and subsequent snapshots of that id report non-existence. Snapshots must not mutate objects—they only read the current mapping. Missing entries in the ids list must be explicitly recorded as empty rather than omitted, otherwise reconciliation will produce false negatives.

    3. Implementation structure

    A hash table can maintain objects, another hash table tracks seen idempotency keys, and snapshot results are appended by label. If point-in-time queries are needed later, versions can be maintained during replay—but if the task only requires snapshots emitted with the log, avoid complex multi-version structures that introduce bugs. Payload parse failures should be treated as invalid events and either skipped or reported by convention; the evaluation must fix this behavior in advance.

    4. Combining the Two Task Families into One Evaluation Protocol

    It is recommended to separate fixed public samples from hidden test cases. Public samples should cover self-loops, empty edge sets, single vertices, duplicate idempotency keys, and ownership-less transfers. Hidden cases should cover: addition at extreme timestamps, mixing period = 1 with extremely large periods, lexicographic ordering of zero-cost multi-paths, ordering of different actors at the same timestamp, snapshots referencing deleted ids, and interleaved add and delete. Scoring should not check only “non-empty output”—each element of the triple must be compared, and paths must match exactly.

    Interpretation of results should distinguish algorithmic errors (relaxation direction, objective ordering), engineering errors (overflow, modular arithmetic), and reduction errors (idempotency, ownership). If a coding tool can restate the problem but its implementation lacks tie-breaking, alignment is stuck at the summary level; if public samples pass but hidden cases fail, adversarial self-testing is missing. Developers can require the model to write invariants and complexity proofs before code, which often reduces “looks runnable” false positives.

    5. Practical Recommendations for Production

    In real systems, periodic departures, windowed admission, and rate-limit slots are isomorphic to the first task family and can reuse the same “next valid moment” formula for scheduling. Log-based systems are isomorphic to the second: out-of-order delivery, exactly-once semantics, and ownership-based authorization. Treat evaluation problems as design problems rather than competitive programming problems. The payoff is that the team is forced to write out states, comparators, and ignore rules, giving code review a concrete checklist.

    In implementation, prioritize comparator transitivity to avoid non-deterministic results from unstable path comparison. For graph algorithms, store adjacency lists in the original edge order so lexicographic tie-breaks are reproducible. For logs, the sort key must include all three fields; omitting actor or op_id causes divergence on same-second conflicts. Test data generators should be able to inject parallel zero-cost edges and duplicate idempotency keys, rather than generating only random connected graphs.

    6. Summary

    Evaluating coding capability requires tasks that combine multiple objectives, discrete constraints, and state machine rules, with layered test cases that expose pitfalls in waiting formulas, lexicographic ordering, large integers, idempotency, and ownership. The first task family tests triple optimization over time, cost, and path on graphs; the second tests ordered replay and authorization. Writing invariants clearly predicts production behavior far better than stacking algorithm names. By organizing evaluations along the protocol above, developers can objectively judge—without relying on any vendor’s marketing—whether an AI coding tool reaches a maintainable engineering standard.