﻿# Doctest ellipsis can weaken a generated code task’s output oracle

A practical investigation of doctest ellipsis can weaken a generated code task’s output oracle, with explicit observations, control cases and evidence limits.

Author: Retrivium team
Updated: 2026-11-06
Canonical URL: https://retrivium.ai/journal/field-synthetic-doctest-ellipsis-generated-code-oracle/
Language: en

## The generated-data scenario

A code-task generator shortens long expected outputs with an ellipsis marker and enables permissive doctest matching. A candidate produces an incorrect middle section but passes. The generator records that candidate as a verified solution and uses it for training. The acceptance question is what the executable comparator actually constrains, rather than whether the expected example looks specific to a human reading the task.

## The generation mechanism

Python doctest documents that ELLIPSIS can match arbitrary substrings, including across lines or an empty substring. The reviewed OutputChecker implementation applies its selected comparison options to expected and actual text. These flags are part of the oracle. An ellipsis intended to ignore one unstable representation can also hide meaningful content if its placement spans the result that distinguishes a correct implementation from an incorrect one.

## Define the dataset contract

Define the invariant the task intends to test and identify every deliberately ignored fragment. Keep the full reference behavior and the reduced display example as separate artifacts when they serve different purposes. Do not infer semantic coverage from the visual length of an expected-output block. A generator that writes both solution and tests needs an independent review of which wrong candidates the chosen comparator is capable of rejecting.

## A step-by-step protocol

First inspect expected output, global option flags and per-example directives. Create harmless candidate outputs with the correct prefix and suffix but an intentionally wrong middle, an added line and a missing meaningful fragment. Compare strict matching with the selected ellipsis behavior. Run the actual task-packaging and grading path in isolation using trusted fixtures, then verify that rejected and accepted outcomes match the intended specification rather than a convenient formatting rule.

## Evidence required for acceptance

Acceptance evidence includes the exact oracle text, comparison flags, known-correct control and deliberately incorrect candidate outcomes. A negative fixture must detect an overbroad match before such a task enters the synthetic release. Preserve any accepted formatting tolerance with its justification. The reference implementation passing its own generated test is insufficient evidence; the test should demonstrate rejection of mistakes that the task claims to distinguish.

## Failure cases and limits

This protocol does not prohibit ellipsis or claim strict textual comparison is the best oracle for every coding task. Some outputs legitimately contain unstable addresses or formatting. The requirement is to state what is ignored and what remains enforced. The bounded result is an auditable generated-task comparator, without turning a passing permissive doctest into proof of algorithmic correctness, security or generalization beyond the tested invariants.

## Primary references and related reading

Treat expected output and matching flags as one oracle; ellipsis can accept differences beyond the intended variable fragment. [Python doctest output matching flags](https://docs.python.org/3/library/doctest.html); [CPython doctest OutputChecker matching implementation](https://raw.githubusercontent.com/python/cpython/main/Lib/doctest.py).

The proposed investigation of doctest ellipsis generated code oracle is a proposed dataset-contract review; no production dataset was generated or evaluated. Related reading: [HumanEval: match function entry points to execution tests](/journal/data-guide-humaneval-entrypoint-tests/); [Magicoder OSS-Instruct: track code seeds in synthetic instruction data](/journal/data-guide-magicoder-code-seed-provenance/).
