I tested a simple question: when a coding model adds code, does it reuse an existing shared helper, or does it copy the inline duplicates around it?
Supporting data covers the setup, per-subject results and limits.
Every subject has two arms:
The helper, the task and the target file are identical in both arms. The task asks for exactly what the helper does.
A structural evaluator labels each output reused or duplicated from the code itself. Hidden tests check correctness separately. Each subject × arm cell ran twice. I compared the arms per subject with an exact paired sign test.
The synthetic set has twelve subjects. Each target file has ten callers of the helper, and a growing number of them are written inline. The table shows cells that reused the helper, out of 24.
| Inline callers | Sol | Sonnet | Gemini | Haiku 4.5 |
|---|---|---|---|---|
| 0 of 10 | 24 | 23 | 21 | 15 |
| 1 of 10 | 24 | 23 | 20 | 10 |
| 5 of 10 | 20 | 21 | 15 | 11 |
| 10 of 10 | 2 | 14 | 0 | 2 |
Two further variants changed nothing: chaining five additions did not snowball, and padding the repository to 90 KB had no effect.
The real-code set has eleven subjects, taken from pinned snapshots of jig and scout.
Retry-After header.The table shows cells that reused the helper, out of 22, as clean / inconsistent.
| Target module | Haiku 4.5 | Gemini 3.1 Pro | GPT-6 Luna | GPT-6.1 Sol |
|---|---|---|---|---|
| No helper import | 4 / 2 | 9 / 8 | 6 / 4 | — |
| Imports the helper | 8 / 8 | — | 16 / 18 | 18 / 18 |
| Plus an inline neighbour in the same file | 6 / 9 | 13 / 12 | 17 / 15 | 18 / 16 |
No arm difference was significant (every sign test p ≥ 0.5). Clean and inconsistent counts differ by at most 2 cells, except Haiku’s same-file run (6 / 9).
Without the import, every model mostly reimplemented the behaviour, in both arms. With reuse that low even in clean code, the mess had nothing to change.
Adding the import, identical in both arms, raised clean-arm reuse:
The inconsistent arm rose just as much.
In the last variant, the target module also holds a neighbour function that needs the same behaviour. In the clean arm the neighbour calls the helper. In the inconsistent arm it inlines the logic.
On 10 of 11 subjects this changed at most one cell. The exception was
usage-cost:
stamp_cost in all 4 clean cells.compute_cost instead.# clean: stamp_cost(usage, payload["model"])
# inconsistent: if cost is None: cost = compute_cost(payload["model"], ...)
Both versions pass the tests. The neighbour calls a legitimate shared function, so copying it reads as local style rather than a shortcut.
Gemini and Haiku duplicated this subject in the clean arm too. They never reused the helper here, so the mess had nothing to pull them away from.
These comparisons count reused cells per subject, with the helper imported.
| Comparison | Subjects where the first reused more | Subjects where it reused less | Sign test |
|---|---|---|---|
| Sol vs Haiku 4.5 | 6 | 0 | p = 0.03 |
| Luna vs Haiku 4.5 | 5 | 0 | p = 0.06 |
| Luna vs Sol | ≤ 1 cell apart on every subject |
The model ordering matches the synthetic results. The experiment was designed to compare arms, so treat these model comparisons as exploratory.
Next steps: