Skip to content

fix: replace a changed paper-local image instead of refusing the save - #95

Merged
917Dhj merged 1 commit into
developfrom
fix/overwrite-image-replace
Nov 8, 2026
Merged

917Dhj merged 1 commit into
developfrom
fix/overwrite-image-replace

Conversation

@917Dhj

@917Dhj 917Dhj commented Nov 8, 2026

Copy link
Copy Markdown
Owner

Summary

Vault image names are fixed by figure label (Figure_1.png), and a paper's notes in both languages share its images/ folder. When a later save carried a new crop under an existing name, Formal Save refused with existing paper-local image has different bytes. That happened on:

  • overwriting the same-language note after a re-crop (seen in the 2026-11-06 real-paper trial, where the agent moved the old image away by hand to finish);
  • adding the other language's note when its run repaired a crop differently.

Formal Save now:

  • backs up the old image inside the save transaction and writes the reviewed new crop;
  • restores the old image if any later step fails, and deletes the backup once the save succeeds;
  • reports each replacement in the save receipt as replaced_images: [{file, also_embedded_by}]. also_embedded_by names the other .md files directly in the paper folder that embed the image, which is usually the other language's note.

SKILL.md gains one final-report line: when a replaced image is shared with other notes, say that the new crop also shows there.

Unchanged:

  • Two insert decisions in one run that give different bytes to the same filename are still refused.
  • Images the new note no longer embeds are left in place.

Evidence

  • New tests/test_image_replacement.py (real Formal Save runs):
    • a same-language overwrite replaces the image and leaves no backup;
    • an English save replaces the image shared with the Chinese note and names it in also_embedded_by;
    • unchanged bytes are not reported;
    • a save that fails after the image step restores the old image and the old note.
  • test_visual_asset_bindings.py: the refusal test becomes a backup-then-replace test, plus a test that only sibling notes embedding the image are named (not the target note, nested folders, or unrelated notes).
  • The CLI test that pinned the refusal for a second-language save is removed; the new English-save test replaces it.
  • python3 -m pytest -q -n auto: 1734 passed, 1 skipped. python3 -m ruff check skills tests: clean.

Merge Danger

  • Low. A replaced shared image changes how that figure looks in the other language's note as well. This was chosen on purpose: same PDF, same label, and the new crop passed visual review.
  • A process killed between backup and cleanup can leave a hidden .<name>.backup file in images/, the same as the existing note backups.

🤖 Generated with Claude Code

Overwriting a note, or adding the other language's note, re-crops figures
under the same label-based filename. Formal Save refused whenever the
existing image had other bytes, so the save could only finish after
someone moved the old image out by hand.

Formal Save now backs up the old image, writes the reviewed new crop,
restores the old image if any later step fails, and deletes the backup
on success. The save receipt lists each replacement in `replaced_images`
with the other notes in the paper folder that also embed it, and the
final report mentions those shared images.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@917Dhj
917Dhj merged commit d1c1216 into develop Nov 8, 2026
3 checks passed
@917Dhj
917Dhj deleted the fix/overwrite-image-replace branch November 8, 2026 14:37
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