Skip to content

Preserve WebP batches when export fails - #250

Merged
Eli Pinkerton (wallstop) merged 4 commits into
mainfrom
fix/docs-webp-publication
Oct 16, 2026
Merged

Eli Pinkerton (wallstop) merged 4 commits into
mainfrom
fix/docs-webp-publication

Conversation

@wallstop

@wallstop Eli Pinkerton (wallstop) commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

DISCLOSURE: LLM-GENERATED TEXT

Why: A late export write failure leaves documentation images from different batches.

What:

  • Stage changed images before replacing published WebPs.
  • Restore previous files and timestamps after publication failures.
  • Retain recovery files when restoration is blocked.
  • Cover staging, replacement, interruption, and rollback failures.

Refs #114.


Note

Low Risk
Local docs export tooling and tests only; no runtime, auth, or CI image pipeline behavior beyond safer atomic writes.

Overview
The docs WebP exporter now publishes the entire pending batch atomically instead of replacing files one at a time, so a mid-run failure cannot leave docs/images/ with a mix of old and new captures.

_publish_batch stages encoded files under .docs-webp-*, backs up existing outputs, then os.replaces them. On failure it rolls back using filesystem state (restoring prior bytes/timestamps or removing new files) and rejects non-regular output paths before any write. If rollback cannot complete, it keeps the recovery directory and surfaces paths in the error.

Troubleshooting documents the staging, restore, and manual recovery steps. Tests cover staging/publication/interruption failures, incomplete rollback, and directory outputs.

Reviewed by Cursor Bugbot for commit 5bc42c3. Bugbot is set up for automated code reviews on this repo. Configure here.

The exporter validates every PNG first but replaces each WebP immediately after staging that one file. A later write or replace failure leaves the published directory mixed. Stage all changed images and prior-file backups before replacement, then restore consumed entries on failure. Preserve existing bytes and timestamps, remove new outputs, and retain recovery data with actionable diagnostics if rollback is blocked.

Six original-code regression variants reproduced partial publication. Additional cases cover interruption after replacement, blocked restoration or metadata inspection, and a non-file target. Original tests remain; all 39 harness files, strict pyright with optional pinned Pillow, fast check, ten final-gate steps, strict docs build, and npm pack dry run pass. Real codec validation produces the same six committed WebPs and preserves timestamps on repeat. No Unity, image pixels, dependencies, or CI workflow changes.

Refs #114.
Use the supported rmtree callback for each interpreter, matching existing harness cleanup, while retaining read-only backup handling. Mock both public metadata entry points so the failure-injection contract does not depend on pathlib method delegation.

Strict typing passes for Python 3.10 and 3.12 targets; fast check, all twelve exporter cases and ten applicable gate steps pass. No CI workflow or dependency changes. Refs #114.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4e7503a. Configure here.

Comment thread scripts/export_docs_webp.py
A second KeyboardInterrupt in the undo loop bypassed the restoration error collector and ran staging cleanup, deleting the only remaining old images. The regression reproduces missing recovery data at 4e7503a.

Make staging cleanup conditional before the first public mutation. One owner enables cleanup only while staging or after a complete publication/restoration. Capture rollback interruption details and retain recovery data by default; verify interruption both before and after an undo replacement. This addresses the configured review finding on PR #250.

All 39 harness files, twelve exporter methods, Python 3.10/3.12 strict typing, fast check, ten gate steps, and strict docs build pass. Real codec publication remains byte-identical to the six committed WebPs and repeated export preserves timestamps. Three content files, 203 changed lines against main; no new dependencies or CI workflow changes. Refs #114.
@wallstop
Eli Pinkerton (wallstop) merged commit c898368 into main Oct 16, 2026
5 checks passed
@wallstop
Eli Pinkerton (wallstop) deleted the fix/docs-webp-publication branch October 16, 2026 01:02
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