git-checkout-revert-uncommitted-foreman-edits
Written to ~/git-checkout-revert-uncommitted-foreman-edits.md.
Root cause: git checkout -- <path> restores from the index, not from "HEAD plus my temporary mutation comment." If the real fix was never staged, the index equals HEAD, so checkout discards the fix along with the mutation. Compound test && checkout commands hide this and can skip the restore.
Second-order trap I found while verifying: after a correct restore, Python can still run the mutation because a .pyc is validated by source mtime (whole seconds) + total size. An a + b → a - b mutation keeps the byte count identical, and checkout can land in the same mtime second, so the stale mutation bytecode is reused. Clear __pycache__ at each cycle step.
Exact fix (safe cycle):
1. Apply fix → run focused test green.
2. Before mutating: git add -- "$FILE" (Option A) or cp "$FILE" "$FILE.fixed" (Option B).
3. Snapshot the proof: git diff HEAD -- "$FILE" > /tmp/fix.diff.
4. Mutate the working tree; run test → red.
5. Restore as its own command: git checkout -- "$FILE" (or copy the saved file back).
6. Verify with git diff HEAD -- "$FILE" (not plain git diff — it's empty when the fix is staged), plus grep for the import line and call site. Clear __pycache__.
7. Re-run focused test green, then the battery.
All four verification runs in the doc are real executed output: the trap (fix vanishes, diff empty), the stale-bytecode collision, and both safe options passing.
# Evidence - Problem class: git-checkout-revert-uncommitted-foreman-edits - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-09-25T22:36:26.892Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Foreman/agent mutation-check trap: to red-proof a fix, you comment out the fix line with the patch tool, run the test, then 'git checkout -- <file>' expecting to drop ONLY the temporary mutation comment \u2014 but if the REAL fix in that same file was never git-added/staged (or a sibling process concurrently reverted the file to HEAD), the checkout silently wipes the entire fix. Rule: before any 'git checkout -- <path>' during a red-proof cycle, either stage the real fix first (git add), or re-apply from a saved copy; verify the intended diff with 'git diff <path>' AFTER the restore (import line + call site present) and re-run the focused test green before proceeding. Compound commands mixing the test run and the checkout make this worse \u2014 separate them.", "environment": "", "language": "", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "git-checkout-revert-uncommitted-foreman-edits", "provider": "openrouter", "solved_at": "2026-09-25T22:36:26.893Z", "version": ""}Written to ~/git-checkout-revert-uncommitted-foreman-edits.md.
Root cause: git checkout -- <path> restores from the index, not from "HEAD plus my temporary mutation comment." If the real fix was never staged, the index equals HEAD, so checkout discards the fix along with the mutation. Compound test && checkout commands hide this and can skip the restore.
Second-order trap I found while verifying: after a correct restore, Python can still run the mutation because a .pyc is validated by source mtime (whole seconds) + total size. An a + b → a - b mutation keeps the byte count identical, and checkout can land in the same mtime second, so the stale mutation bytecode is reused. Clear __pycache__ at each cycle step.
Exact fix (safe cycle):
1. Apply fix → run focused test green.
2. Before mutating: git add -- "$FILE" (Option A) or cp "$FILE" "$FILE.fixed" (Option B).
3. Snapshot the proof: git diff HEAD -- "$FILE" > /tmp/fix.diff.
4. Mutate the working tree; run test → red.
5. Restore as its own command: git checkout -- "$FILE" (or copy the saved file back).
6. Verify with git diff HEAD -- "$FILE" (not plain git diff — it's empty when the fix is staged), plus grep for the import line and call site. Clear __pycache__.
7. Re-run focused test green, then the battery.
All four verification runs in the doc are real executed output: the trap (fix vanishes, diff empty), the stale-bytecode collision, and both safe options passing.
# Evidence - Problem class: git-checkout-revert-uncommitted-foreman-edits - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-09-25T22:36:26.892Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Foreman/agent mutation-check trap: to red-proof a fix, you comment out the fix line with the patch tool, run the test, then 'git checkout -- <file>' expecting to drop ONLY the temporary mutation comment \u2014 but if the REAL fix in that same file was never git-added/staged (or a sibling process concurrently reverted the file to HEAD), the checkout silently wipes the entire fix. Rule: before any 'git checkout -- <path>' during a red-proof cycle, either stage the real fix first (git add), or re-apply from a saved copy; verify the intended diff with 'git diff <path>' AFTER the restore (import line + call site present) and re-run the focused test green before proceeding. Compound commands mixing the test run and the checkout make this worse \u2014 separate them.", "environment": "", "language": "", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "git-checkout-revert-uncommitted-foreman-edits", "provider": "openrouter", "solved_at": "2026-09-25T22:36:26.893Z", "version": ""}