Skip to content

loopguard: count every file a multi-file patch changes, not only the first - #225

Open
Lanre Shittu (Shizoqua) wants to merge 1 commit into
microsoft:mainfrom
Shizoqua:fix-loopguard-patch-files
Open

Lanre Shittu (Shizoqua) wants to merge 1 commit into
microsoft:mainfrom
Shizoqua:fix-loopguard-patch-files

Conversation

@Shizoqua

Copy link
Copy Markdown

One apply_patch call can change several files. The Codex, Droid and Hermes hosts and the Codex rollout reader pass them all as paths, with the first as path, but SpiralState.update read only path. A patch that changed three files counted as one edit to the first, so edit_churn and distinct_edit_files, which is_stuck and the learned envelope read, came out low. The same patch run through the shell (apply_patch <<'PATCH') already counted each file.

Fix: an edit tool's call now counts each distinct file in paths once, and falls back to the single path as before when there is no list. The judge's digest names the files (edit a.py, b.py, test_c.py).

Test, in tests/test_live_core.py next to the other edit-counting tests: test_a_patch_that_changes_several_files_counts_each_of_them sends a three-file patch through hosts.Codex().tool_call and TurnGuard.fold, and the same patch through the shell form. On main it fails with {'a.py': 1} == {'a.py': 1, 'b.py': 1, 'test_c.py': 1}; with the fix both forms give the same counts.

Also checked on a made-up Codex rollout with one FileChange over three files, read through trace.codex_rollout_to_exec and state_from_trajectory: distinct_edit_files is 1 on main and 3 with the fix.

python -m pytest tests -rfEs --tb=line
1001 passed, 17 skipped

The skips need a real Codex, Hermes, opencode or aider, Windows, or a non-root user.

Fixes #223

…first

One `apply_patch` call can change several files. The Codex, Droid and Hermes hosts and the Codex
rollout reader pass them all as `paths` (with the first as `path`), but `SpiralState.update` read
only `path`. A patch that changed three files counted as one edit to the first, so
`edit_churn` and `distinct_edit_files`, which `is_stuck` and the learned envelope read, came out
low. The same patch run through the shell (`apply_patch <<'PATCH'`) already counted each file.

An edit tool's call now counts each distinct file in `paths` once, and falls back to the single
path as before when there is no list.
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.

loopguard: a patch that changes several files counts as one edit to the first

1 participant