Skip to content

Tolerate a uniform indentation shift when it is still unique (#195 Tier 1) - #210

Merged
thedancingdeveloper merged 1 commit into
mainfrom
fix/195-tolerate-a-uniform-indent-shift
Aug 5, 2026
Merged

Tolerate a uniform indentation shift when it is still unique (#195 Tier 1)#210
thedancingdeveloper merged 1 commit into
mainfrom
fix/195-tolerate-a-uniform-indent-shift

Conversation

@thedancingdeveloper

Copy link
Copy Markdown
Contributor

Part of #195. Does not close it.

Once hunk arithmetic stopped losing items, this became the dominant failure. Measured on rdpapp across two consecutive passes:

T2: the SEARCH text does not occur in the file as whole lines.
    It must match exactly, including indentation.

A model that reproduces the right lines and indents them differently has named a location correctly and formatted it wrongly. Refusing that loses a whole item for a mistake with no ambiguity in it.

Still refused — everything with a choice in it

Exact match is tried first. Only on failure is a shifted match considered, and it must satisfy all three:

One-for-one stripped lines must correspond exactly
Same shift every line moves by the same amount, so a different shape wearing the same words is not a shift
Unique two candidates is still not a location

The replacement is shifted by the same amount, so the file keeps its own indentation rather than the model's.

test_indentation_must_match is replaced, not deleted — the boundary still exists, it has moved. Three tests pin the new one: a unique shift applies, an ambiguous one is refused, a changed shape is refused rather than silently re-indented.

28 tests. ruff, mypy clean.

🤖 Generated with Claude Code

… Tier 1)

Once hunk arithmetic stopped losing items, this became the dominant failure.
Measured on rdpapp, two consecutive passes:

    T2: the SEARCH text does not occur in the file as whole lines.
        It must match exactly, including indentation.

A model that reproduces the right lines and indents them differently has
named a location correctly and formatted it wrongly. Refusing that costs a
whole item for a mistake with no ambiguity in it -- which is not the trade the
exact matcher was defending.

So an exact match is tried first, and only when it fails is a shifted match
considered. Everything with a *choice* in it is still refused:

- the stripped lines must correspond one for one;
- every line must move by the same amount, so a different shape wearing the
  same words is not accepted as a shift;
- it must match in exactly one place. Two candidates is still not a location.

The replacement is shifted by the same amount, so the result keeps the file's
own indentation rather than the model's.

`test_indentation_must_match` is replaced rather than deleted: the boundary it
guarded still exists, it has just moved. Three tests now pin it -- a unique
shift is applied, an ambiguous one is refused, and a changed shape is refused
rather than silently re-indented.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@thedancingdeveloper
thedancingdeveloper merged commit 6c68307 into main Aug 5, 2026
2 checks passed
@thedancingdeveloper
thedancingdeveloper deleted the fix/195-tolerate-a-uniform-indent-shift branch August 5, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant